From c6c89bffdc7cc238aa900f8f79ffc61f612e3d63 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 16 Jan 2018 22:13:15 +0000 Subject: [PATCH] [CallSiteSplitting] Pass list of (BB, Conditions) pairs to splitCallSite. This removes some duplication from splitCallSite and makes it easier to add additional code dealing with each predecessor. It also allows us to split for more than 2 predecessors, although that is not enabled for now. Reviewers: junbuml, mcrosier, davidxl, davide Reviewed By: junbuml Differential Revision: https://reviews.llvm.org/D41858 llvm-svn: 322599 --- .../Transforms/Scalar/CallSiteSplitting.cpp | 143 +++++++++--------- .../callsite-no-or-structure.ll | 40 ++--- .../CallSiteSplitting/callsite-split-debug.ll | 6 +- .../callsite-split-or-phi.ll | 130 ++++++++-------- .../CallSiteSplitting/callsite-split.ll | 8 +- 5 files changed, 161 insertions(+), 166 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp index caa73b2ff01c..3243731f07db 100644 --- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp +++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp @@ -73,9 +73,7 @@ using namespace PatternMatch; STATISTIC(NumCallSiteSplit, "Number of call-site split"); -static void addNonNullAttribute(Instruction *CallI, Instruction *NewCallI, - Value *Op) { - CallSite CS(NewCallI); +static void addNonNullAttribute(CallSite CS, Value *Op) { unsigned ArgNo = 0; for (auto &I : CS.args()) { if (&*I == Op) @@ -84,9 +82,8 @@ static void addNonNullAttribute(Instruction *CallI, Instruction *NewCallI, } } -static void setConstantInArgument(Instruction *CallI, Instruction *NewCallI, - Value *Op, Constant *ConstValue) { - CallSite CS(NewCallI); +static void setConstantInArgument(CallSite CS, Value *Op, + Constant *ConstValue) { unsigned ArgNo = 0; for (auto &I : CS.args()) { if (&*I == Op) @@ -111,11 +108,13 @@ static bool isCondRelevantToAnyCallArgument(ICmpInst *Cmp, CallSite CS) { return false; } +typedef std::pair ConditionTy; +typedef SmallVector ConditionsTy; + /// If From has a conditional jump to To, add the condition to Conditions, /// if it is relevant to any argument at CS. -static void -recordCondition(const CallSite &CS, BasicBlock *From, BasicBlock *To, - SmallVectorImpl> &Conditions) { +static void recordCondition(CallSite CS, BasicBlock *From, BasicBlock *To, + ConditionsTy &Conditions) { auto *BI = dyn_cast(From->getTerminator()); if (!BI || !BI->isConditional()) return; @@ -136,9 +135,8 @@ recordCondition(const CallSite &CS, BasicBlock *From, BasicBlock *To, /// Record ICmp conditions relevant to any argument in CS following Pred's /// single successors. If there are conflicting conditions along a path, like /// x == 1 and x == 0, the first condition will be used. -static void -recordConditions(const CallSite &CS, BasicBlock *Pred, - SmallVectorImpl> &Conditions) { +static void recordConditions(CallSite CS, BasicBlock *Pred, + ConditionsTy &Conditions) { recordCondition(CS, Pred, CS.getInstruction()->getParent(), Conditions); BasicBlock *From = Pred; BasicBlock *To = Pred; @@ -150,24 +148,17 @@ recordConditions(const CallSite &CS, BasicBlock *Pred, } } -static Instruction * -addConditions(CallSite &CS, - SmallVectorImpl> &Conditions) { - if (Conditions.empty()) - return nullptr; - - Instruction *NewCI = CS.getInstruction()->clone(); +static void addConditions(CallSite CS, const ConditionsTy &Conditions) { for (auto &Cond : Conditions) { Value *Arg = Cond.first->getOperand(0); Constant *ConstVal = cast(Cond.first->getOperand(1)); if (Cond.second == ICmpInst::ICMP_EQ) - setConstantInArgument(CS.getInstruction(), NewCI, Arg, ConstVal); + setConstantInArgument(CS, Arg, ConstVal); else if (ConstVal->getType()->isPointerTy() && ConstVal->isNullValue()) { assert(Cond.second == ICmpInst::ICMP_NE); - addNonNullAttribute(CS.getInstruction(), NewCI, Arg); + addNonNullAttribute(CS, Arg); } } - return NewCI; } static SmallVector getTwoPredecessors(BasicBlock *BB) { @@ -200,14 +191,17 @@ static bool canSplitCallSite(CallSite CS) { return CallSiteBB->canSplitPredecessors(); } -/// Return true if the CS is split into its new predecessors which are directly -/// hooked to each of its original predecessors pointed by PredBB1 and PredBB2. -/// CallInst1 and CallInst2 will be the new call-sites placed in the new -/// predecessors split for PredBB1 and PredBB2, respectively. +/// Return true if the CS is split into its new predecessors. +/// +/// For each (predecessor, conditions from predecessors) pair, it will split the +/// basic block containing the call site, hook it up to the predecessor and +/// replace the call instruction with new call instructions, which contain +/// constraints based on the conditions from their predecessors. /// For example, in the IR below with an OR condition, the call-site can -/// be split. Assuming PredBB1=Header and PredBB2=TBB, CallInst1 will be the -/// call-site placed between Header and Tail, and CallInst2 will be the -/// call-site between TBB and Tail. +/// be split. In this case, Preds for Tail is [(Header, a == null), +/// (TBB, a != null, b == null)]. Tail is replaced by 2 split blocks, containing +/// CallInst1, which has constraints based on the conditions from Head and +/// CallInst2, which has constraints based on the conditions coming from TBB. /// /// From : /// @@ -240,55 +234,50 @@ static bool canSplitCallSite(CallSite CS) { /// Note that in case any arguments at the call-site are constrained by its /// predecessors, new call-sites with more constrained arguments will be /// created in createCallSitesOnPredicatedArgument(). -static void splitCallSite(CallSite CS, BasicBlock *PredBB1, BasicBlock *PredBB2, - Instruction *CallInst1, Instruction *CallInst2) { +static void splitCallSite( + CallSite CS, + const SmallVectorImpl> &Preds) { Instruction *Instr = CS.getInstruction(); BasicBlock *TailBB = Instr->getParent(); - assert(Instr == (TailBB->getFirstNonPHIOrDbg()) && "Unexpected call-site"); - BasicBlock *SplitBlock1 = - SplitBlockPredecessors(TailBB, PredBB1, ".predBB1.split"); - BasicBlock *SplitBlock2 = - SplitBlockPredecessors(TailBB, PredBB2, ".predBB2.split"); + PHINode *CallPN = nullptr; + if (Instr->getNumUses()) + CallPN = PHINode::Create(Instr->getType(), Preds.size(), "phi.call"); - assert((SplitBlock1 && SplitBlock2) && "Unexpected new basic block split."); + DEBUG(dbgs() << "split call-site : " << *Instr << " into \n"); + for (const auto &P : Preds) { + BasicBlock *PredBB = P.first; + BasicBlock *SplitBlock = + SplitBlockPredecessors(TailBB, PredBB, ".predBB.split"); + assert(SplitBlock && "Unexpected new basic block split."); - if (!CallInst1) - CallInst1 = Instr->clone(); - if (!CallInst2) - CallInst2 = Instr->clone(); + Instruction *NewCI = Instr->clone(); + CallSite NewCS(NewCI); + addConditions(NewCS, P.second); + NewCI->insertBefore(&*SplitBlock->getFirstInsertionPt()); - CallInst1->insertBefore(&*SplitBlock1->getFirstInsertionPt()); - CallInst2->insertBefore(&*SplitBlock2->getFirstInsertionPt()); - - CallSite CS1(CallInst1); - CallSite CS2(CallInst2); - - // Handle PHIs used as arguments in the call-site. - for (PHINode &PN : TailBB->phis()) { - unsigned ArgNo = 0; - for (auto &CI : CS.args()) { - if (&*CI == &PN) { - CS1.setArgument(ArgNo, PN.getIncomingValueForBlock(SplitBlock1)); - CS2.setArgument(ArgNo, PN.getIncomingValueForBlock(SplitBlock2)); + // Handle PHIs used as arguments in the call-site. + for (PHINode &PN : TailBB->phis()) { + unsigned ArgNo = 0; + for (auto &CI : CS.args()) { + if (&*CI == &PN) { + NewCS.setArgument(ArgNo, PN.getIncomingValueForBlock(SplitBlock)); + } + ++ArgNo; } - ++ArgNo; } + DEBUG(dbgs() << " " << *NewCI << " in " << SplitBlock->getName() + << "\n"); + if (CallPN) + CallPN->addIncoming(NewCI, SplitBlock); } // Replace users of the original call with a PHI mering call-sites split. - if (Instr->getNumUses()) { - PHINode *PN = PHINode::Create(Instr->getType(), 2, "phi.call", - TailBB->getFirstNonPHI()); - PN->addIncoming(CallInst1, SplitBlock1); - PN->addIncoming(CallInst2, SplitBlock2); - Instr->replaceAllUsesWith(PN); + if (CallPN) { + CallPN->insertBefore(TailBB->getFirstNonPHI()); + Instr->replaceAllUsesWith(CallPN); } - DEBUG(dbgs() << "split call-site : " << *Instr << " into \n"); - DEBUG(dbgs() << " " << *CallInst1 << " in " << SplitBlock1->getName() - << "\n"); - DEBUG(dbgs() << " " << *CallInst2 << " in " << SplitBlock2->getName() - << "\n"); + Instr->eraseFromParent(); NumCallSiteSplit++; } @@ -326,7 +315,9 @@ static bool tryToSplitOnPHIPredicatedArgument(CallSite CS) { return false; auto Preds = getTwoPredecessors(CS.getInstruction()->getParent()); - splitCallSite(CS, Preds[0], Preds[1], nullptr, nullptr); + SmallVector, 2> PredsCS = { + {Preds[0], {}}, {Preds[1], {}}}; + splitCallSite(CS, PredsCS); return true; } @@ -335,16 +326,20 @@ static bool tryToSplitOnPredicatedArgument(CallSite CS) { if (Preds[0] == Preds[1]) return false; - SmallVector, 2> C1, C2; - recordConditions(CS, Preds[0], C1); - recordConditions(CS, Preds[1], C2); + SmallVector, 2> PredsCS; + for (auto *Pred : make_range(Preds.rbegin(), Preds.rend())) { + ConditionsTy Conditions; + recordConditions(CS, Pred, Conditions); + PredsCS.push_back({Pred, Conditions}); + } - Instruction *CallInst1 = addConditions(CS, C1); - Instruction *CallInst2 = addConditions(CS, C2); - if (!CallInst1 && !CallInst2) + if (std::all_of(PredsCS.begin(), PredsCS.end(), + [](const std::pair &P) { + return P.second.empty(); + })) return false; - splitCallSite(CS, Preds[1], Preds[0], CallInst2, CallInst1); + splitCallSite(CS, PredsCS); return true; } diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-no-or-structure.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-no-or-structure.ll index e10b04a850af..78c287e78ea4 100644 --- a/llvm/test/Transforms/CallSiteSplitting/callsite-no-or-structure.ll +++ b/llvm/test/Transforms/CallSiteSplitting/callsite-no-or-structure.ll @@ -3,15 +3,15 @@ ; CHECK-LABEL: @test_simple ; CHECK-LABEL: Header: -; CHECK-NEXT: br i1 undef, label %Tail.predBB1.split +; CHECK-NEXT: br i1 undef, label %Tail.predBB.split ; CHECK-LABEL: TBB: -; CHECK: br i1 %cmp, label %Tail.predBB2.split -; CHECK-LABEL: Tail.predBB1.split: +; CHECK: br i1 %cmp, label %Tail.predBB.split1 +; CHECK-LABEL: Tail.predBB.split: ; CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 %p) -; CHECK-LABEL: Tail.predBB2.split: +; CHECK-LABEL: Tail.predBB.split1: ; CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 %v, i32 %p) ; CHECK-LABEL: Tail -; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ; CHECK: ret i32 %[[MERGED]] define i32 @test_simple(i32* %a, i32 %v, i32 %p) { Header: @@ -31,15 +31,15 @@ End: ; CHECK-LABEL: @test_eq_eq_eq_untaken ; CHECK-LABEL: Header: -; CHECK: br i1 %tobool1, label %TBB1, label %Tail.predBB1.split +; CHECK: br i1 %tobool1, label %TBB1, label %Tail.predBB.split ; CHECK-LABEL: TBB2: -; CHECK: br i1 %cmp2, label %Tail.predBB2.split, label %End -; CHECK-LABEL: Tail.predBB1.split: +; CHECK: br i1 %cmp2, label %Tail.predBB.split1, label %End +; CHECK-LABEL: Tail.predBB.split: ; CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p) -; CHECK-LABEL: Tail.predBB2.split: +; CHECK-LABEL: Tail.predBB.split1: ; CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 99) ; CHECK-LABEL: Tail -; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ; CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq_eq_untaken2(i32* %a, i32 %v, i32 %p) { Header: @@ -64,15 +64,15 @@ End: ; CHECK-LABEL: @test_eq_ne_eq_untaken ; CHECK-LABEL: Header: -; CHECK: br i1 %tobool1, label %TBB1, label %Tail.predBB1.split +; CHECK: br i1 %tobool1, label %TBB1, label %Tail.predBB.split ; CHECK-LABEL: TBB2: -; CHECK: br i1 %cmp2, label %Tail.predBB2.split, label %End -; CHECK-LABEL: Tail.predBB1.split: +; CHECK: br i1 %cmp2, label %Tail.predBB.split1, label %End +; CHECK-LABEL: Tail.predBB.split: ; CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p) -; CHECK-LABEL: Tail.predBB2.split: +; CHECK-LABEL: Tail.predBB.split1: ; CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 %v, i32 99) ; CHECK-LABEL: Tail -; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ; CHECK: ret i32 %[[MERGED]] define i32 @test_eq_ne_eq_untaken(i32* %a, i32 %v, i32 %p) { Header: @@ -97,17 +97,17 @@ End: ; CHECK-LABEL: @test_header_header2_tbb ; CHECK: Header2: -; CHECK:br i1 %tobool2, label %Tail.predBB1.split, label %TBB1 +; CHECK:br i1 %tobool2, label %Tail.predBB.split, label %TBB1 ; CHECK-LABEL: TBB2: -; CHECK: br i1 %cmp2, label %Tail.predBB2.split, label %End -; CHECK-LABEL: Tail.predBB1.split: +; CHECK: br i1 %cmp2, label %Tail.predBB.split1, label %End +; CHECK-LABEL: Tail.predBB.split: ; CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 10) -; CHECK-LABEL: Tail.predBB2.split: +; CHECK-LABEL: Tail.predBB.split1: ; NOTE: CallSiteSplitting cannot infer that %a is null here, as it currently ; only supports recording conditions along a single predecessor path. ; CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 99) ; CHECK-LABEL: Tail -; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +; CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ; CHECK: ret i32 %[[MERGED]] define i32 @test_header_header2_tbb(i32* %a, i32 %v, i32 %p) { Header: diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll index dbd6cd9cc8d3..415b6038f37f 100644 --- a/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll +++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll @@ -48,10 +48,10 @@ attributes #0 = { nounwind readnone speculatable } ; CallSiteBB. ; CHECK-LABEL: @foo -; CHECK-LABEL: CallsiteBB.predBB1.split: +; CHECK-LABEL: CallsiteBB.predBB.split: ; CHECK: [[TMP1:%[0-9]+]] = call i16 @bar(i16 1, i16 5) -; CHECK-LABEL: CallsiteBB.predBB2.split: +; CHECK-LABEL: CallsiteBB.predBB.split1: ; CHECK: [[TMP2:%[0-9]+]] = call i16 @bar(i16 0, i16 5) ; CHECK-LABEL: CallsiteBB -; CHECK: %phi.call = phi i16 [ [[TMP1]], %CallsiteBB.predBB1.split ], [ [[TMP2]], %CallsiteBB.predBB2.split +; CHECK: %phi.call = phi i16 [ [[TMP1]], %CallsiteBB.predBB.split ], [ [[TMP2]], %CallsiteBB.predBB.split1 diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll index e41a81f4b21b..56f194f93f77 100644 --- a/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll +++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll @@ -5,13 +5,13 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64-linaro-linux-gnueabi" ;CHECK-LABEL: @test_eq_eq -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq(i32* %a, i32 %v) { Header: @@ -32,12 +32,12 @@ End: } ;CHECK-LABEL: @test_eq_eq_eq -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 10) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq_eq(i32* %a, i32 %v, i32 %p) { Header: @@ -61,12 +61,12 @@ End: } ;CHECK-LABEL: @test_eq_eq_eq_constrain_same_i32_arg -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 222, i32 %p) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 333, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq_eq_constrain_same_i32_arg(i32* %a, i32 %v, i32 %p) { Header: @@ -90,13 +90,13 @@ End: } ;CHECK-LABEL: @test_ne_eq -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_eq(i32* %a, i32 %v) { Header: @@ -117,12 +117,12 @@ End: } ;CHECK-LABEL: @test_ne_eq_ne -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 10) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_eq_ne(i32* %a, i32 %v, i32 %p) { Header: @@ -146,13 +146,13 @@ End: } ;CHECK-LABEL: @test_ne_ne -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 %v, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_ne(i32* %a, i32 %v) { Header: @@ -173,12 +173,12 @@ End: } ;CHECK-LABEL: @test_ne_ne_ne_constrain_same_pointer_arg -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_ne_ne_constrain_same_pointer_arg(i32* %a, i32 %v, i32 %p, i32* %a2, i32* %a3) { Header: @@ -204,13 +204,13 @@ End: ;CHECK-LABEL: @test_eq_eq_untaken -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq_untaken(i32* %a, i32 %v) { Header: @@ -231,12 +231,12 @@ End: } ;CHECK-LABEL: @test_eq_eq_eq_untaken -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* nonnull %a, i32 %v, i32 10) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_eq_eq_eq_untaken(i32* %a, i32 %v, i32 %p) { Header: @@ -260,13 +260,13 @@ End: } ;CHECK-LABEL: @test_ne_eq_untaken -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_eq_untaken(i32* %a, i32 %v) { Header: @@ -287,12 +287,12 @@ End: } ;CHECK-LABEL: @test_ne_eq_ne_untaken -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 10) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* null, i32 %v, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_eq_ne_untaken(i32* %a, i32 %v, i32 %p) { Header: @@ -316,13 +316,13 @@ End: } ;CHECK-LABEL: @test_ne_ne_untaken -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* null, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* nonnull %a, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_ne_ne_untaken(i32* %a, i32 %v) { Header: @@ -343,13 +343,13 @@ End: } ;CHECK-LABEL: @test_nonconst_const_phi -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 2) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 1, %Tail.predBB1.split ], [ 2, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 1, %Tail.predBB.split ], [ 2, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_nonconst_const_phi(i32* %a, i32* %b, i32 %v) { Header: @@ -370,13 +370,13 @@ End: } ;CHECK-LABEL: @test_nonconst_nonconst_phi -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 2) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 2, %Tail.predBB1.split ], [ 1, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 2, %Tail.predBB.split ], [ 1, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_nonconst_nonconst_phi(i32* %a, i32* %b, i32 %v, i32 %v2) { Header: @@ -397,13 +397,13 @@ End: } ;CHECK-LABEL: @test_cfg_no_or_phi -;CHECK-LABEL: Tail.predBB1.split +;CHECK-LABEL: Tail.predBB.split ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 2) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 %v, i32 1) ;CHECK-LABEL: Tail -;CHECK: %p = phi i32 [ 2, %Tail.predBB1.split ], [ 1, %Tail.predBB2.split ] -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %p = phi i32 [ 2, %Tail.predBB.split ], [ 1, %Tail.predBB.split1 ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_cfg_no_or_phi(i32* %a, i32 %v) { entry: @@ -421,8 +421,8 @@ End: } ;CHECK-LABEL: @test_nonconst_nonconst_phi_noncost -;CHECK-NOT: Tail.predBB1.split: -;CHECK-NOT: Tail.predBB2.split: +;CHECK-NOT: Tail.predBB.split: +;CHECK-NOT: Tail.predBB.split1: ;CHECK-LABEL: Tail: ;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p) ;CHECK: ret i32 %r @@ -445,8 +445,8 @@ End: } ;CHECK-LABEL: @test_fisrtnonphi -;CHECK-NOT: Tail.predBB1.split: -;CHECK-NOT: Tail.predBB2.split: +;CHECK-NOT: Tail.predBB.split: +;CHECK-NOT: Tail.predBB.split1: ;CHECK-LABEL: Tail: ;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p) ;CHECK: ret i32 %r @@ -470,8 +470,8 @@ End: } ;CHECK-LABEL: @test_3preds_constphi -;CHECK-NOT: Tail.predBB1.split: -;CHECK-NOT: Tail.predBB2.split: +;CHECK-NOT: Tail.predBB.split: +;CHECK-NOT: Tail.predBB.split1: ;CHECK-LABEL: Tail: ;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p) ;CHECK: ret i32 %r @@ -495,8 +495,8 @@ End: } ;CHECK-LABEL: @test_indirectbr_phi -;CHECK-NOT: Tail.predBB1.split: -;CHECK-NOT: Tail.predBB2.split: +;CHECK-NOT: Tail.predBB.split: +;CHECK-NOT: Tail.predBB.split1: ;CHECK-LABEL: Tail: ;CHECK: %r = call i32 @callee(i32* %a, i32 %v, i32 %p) ;CHECK: ret i32 %r @@ -519,12 +519,12 @@ End: } ;CHECK-LABEL: @test_unreachable -;CHECK-LABEL: Tail.predBB1.split: +;CHECK-LABEL: Tail.predBB.split: ;CHECK: %[[CALL1:.*]] = call i32 @callee(i32* %a, i32 %v, i32 10) -;CHECK-LABEL: Tail.predBB2.split: +;CHECK-LABEL: Tail.predBB.split1: ;CHECK: %[[CALL2:.*]] = call i32 @callee(i32* %a, i32 1, i32 %p) ;CHECK-LABEL: Tail -;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB1.split ], [ %[[CALL2]], %Tail.predBB2.split ] +;CHECK: %[[MERGED:.*]] = phi i32 [ %[[CALL1]], %Tail.predBB.split ], [ %[[CALL2]], %Tail.predBB.split1 ] ;CHECK: ret i32 %[[MERGED]] define i32 @test_unreachable(i32* %a, i32 %v, i32 %p) { Entry: diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll index adc4160cde61..af821690e0ab 100644 --- a/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll +++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll @@ -9,7 +9,7 @@ target triple = "aarch64-linaro-linux-gnueabi" ;CHECK-LABEL: @caller ;CHECK-LABEL: NextCond: ;CHECK: br {{.*}} label %callee.exit -;CHECK-LABEL: CallSiteBB.predBB1.split: +;CHECK-LABEL: CallSiteBB.predBB.split: ;CHECK: call void @callee(%struct.bitmap* null, %struct.bitmap* null, %struct.bitmap* %b_elt, i1 false) ;CHECK-LABEL: callee.exit: ;CHECK: call void @dummy2(%struct.bitmap* %a_elt) @@ -69,12 +69,12 @@ declare void @dummy1(%struct.bitmap*, %struct.bitmap*, %struct.bitmap*, %struct. ;CHECK-LABEL: @caller2 -;CHECK-LABEL: CallSiteBB.predBB1.split: +;CHECK-LABEL: CallSiteBB.predBB.split: ;CHECK: call void @dummy3() -;CHECK-LABEL: CallSiteBB.predBB2.split: +;CHECK-LABEL: CallSiteBB.predBB.split1: ;CHECK: call void @dummy4() ;CheCK-LABEL: CallSiteBB: -;CHECK: %phi.call = phi i1 [ true, %CallSiteBB.predBB1.split ], [ false, %CallSiteBB.predBB2.split ] +;CHECK: %phi.call = phi i1 [ true, %CallSiteBB.predBB.split ], [ false, %CallSiteBB.predBB.split1 ] ;CHECK: call void @foo(i1 %phi.call) define void @caller2(i1 %c, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt, %struct.bitmap* %c_elt) { entry: