llvm.org GIT mirror llvm / 9a28cc1
Teach if-converter to avoid removing BBs whose addresses are takne. rdar://13782395 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181160 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 7 years ago
1 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
10381038 return false;
10391039 }
10401040
1041 if (CvtBBI->BB->hasAddressTaken())
1042 // Conservatively abort if-conversion if BB's address is taken.
1043 return false;
1044
10411045 if (Kind == ICSimpleFalse)
10421046 if (TII->ReverseBranchCondition(Cond))
10431047 llvm_unreachable("Unable to reverse branch condition!");
11151119 return false;
11161120 }
11171121
1122 if (CvtBBI->BB->hasAddressTaken())
1123 // Conservatively abort if-conversion if BB's address is taken.
1124 return false;
1125
11181126 if (Kind == ICTriangleFalse || Kind == ICTriangleFRev)
11191127 if (TII->ReverseBranchCondition(Cond))
11201128 llvm_unreachable("Unable to reverse branch condition!");
11831191 // block. By not merging them, we make it possible to iteratively
11841192 // ifcvt the blocks.
11851193 if (!HasEarlyExit &&
1186 NextBBI->BB->pred_size() == 1 && !NextBBI->HasFallThrough) {
1194 NextBBI->BB->pred_size() == 1 && !NextBBI->HasFallThrough &&
1195 !NextBBI->BB->hasAddressTaken()) {
11871196 MergeBlocks(BBI, *NextBBI);
11881197 FalseBBDead = true;
11891198 } else {
12321241 FalseBBI.IsAnalyzed = false;
12331242 return false;
12341243 }
1244
1245 if (TrueBBI.BB->hasAddressTaken() || FalseBBI.BB->hasAddressTaken())
1246 // Conservatively abort if-conversion if either BB has its address taken.
1247 return false;
12351248
12361249 // Put the predicated instructions from the 'true' block before the
12371250 // instructions from the 'false' block, unless the true block would clobber
13811394 // tail, add a unconditional branch to it.
13821395 if (TailBB) {
13831396 BBInfo &TailBBI = BBAnalysis[TailBB->getNumber()];
1384 bool CanMergeTail = !TailBBI.HasFallThrough;
1397 bool CanMergeTail = !TailBBI.HasFallThrough &&
1398 !TailBBI.BB->hasAddressTaken();
13851399 // There may still be a fall-through edge from BBI1 or BBI2 to TailBB;
13861400 // check if there are any other predecessors besides those.
13871401 unsigned NumPreds = TailBB->pred_size();
15501564 /// i.e., when FromBBI's branch is being moved, add those successor edges to
15511565 /// ToBBI.
15521566 void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) {
1567 assert(!FromBBI.BB->hasAddressTaken() &&
1568 "Removing a BB whose address is taken!");
1569
15531570 ToBBI.BB->splice(ToBBI.BB->end(),
15541571 FromBBI.BB, FromBBI.BB->begin(), FromBBI.BB->end());
15551572