diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -375,7 +375,7 @@ do { Changed = false; for (auto &BB : F) { - if (Unreachable.count(&BB)) + if (Unreachable.count(&BB) || DTU->isBBPendingDeletion(&BB)) continue; while (ProcessBlock(&BB)) // Thread all of the branches we can over BB. Changed = true; @@ -962,16 +962,6 @@ return MinSucc; } -static bool hasAddressTakenAndUsed(BasicBlock *BB) { - if (!BB->hasAddressTaken()) return false; - - // If the block has its address taken, it may be a tree of dead constants - // hanging off of it. These shouldn't keep the block alive. - BlockAddress *BA = BlockAddress::get(BB); - BA->removeDeadConstantUsers(); - return !BA->use_empty(); -} - /// ProcessBlock - If there are any predecessors whose control can be threaded /// through to a successor, transform them now. bool JumpThreadingPass::ProcessBlock(BasicBlock *BB) { @@ -987,45 +977,69 @@ // predecessors of our predecessor block. if (BasicBlock *SinglePred = BB->getSinglePredecessor()) { const Instruction *TI = SinglePred->getTerminator(); - if (!TI->isExceptionalTerminator() && TI->getNumSuccessors() == 1 && - SinglePred != BB && !hasAddressTakenAndUsed(BB)) { - // If SinglePred was a loop header, BB becomes one. - if (LoopHeaders.erase(SinglePred)) - LoopHeaders.insert(BB); - - LVI->eraseBlock(SinglePred); - MergeBasicBlockIntoOnlyPred(BB, DTU); - - // Now that BB is merged into SinglePred (i.e. SinglePred Code followed by - // BB code within one basic block `BB`), we need to invalidate the LVI - // information associated with BB, because the LVI information need not be - // true for all of BB after the merge. For example, - // Before the merge, LVI info and code is as follows: - // SinglePred: - // %y = use of %p - // call @exit() // need not transfer execution to successor. - // assume(%p) // from this point on %p is true - // br label %BB - // BB: - // %x = use of %p - // br label exit - // - // Note that this LVI info for blocks BB and SinglPred is correct for %p - // (info2 and info1 respectively). After the merge and the deletion of the - // LVI info1 for SinglePred. We have the following code: - // BB: - // %y = use of %p - // call @exit() - // assume(%p) - // %x = use of %p <-- LVI info2 is correct from here onwards. - // br label exit - // LVI info2 for BB is incorrect at the beginning of BB. - - // Invalidate LVI information for BB if the LVI is not provably true for - // all of BB. - if (!isGuaranteedToTransferExecutionToSuccessor(BB)) + if (!TI->isExceptionalTerminator() && TI->getNumSuccessors() == 1) { + if (pred_empty(SinglePred) && + SinglePred != &SinglePred->getParent()->getEntryBlock()) { + // We have the following IR shape where SinglePred isn't the entry BB: + // SinglePred: ; No predecessors! + // ... + // br label %BB + // BB: ; preds = %SinglePred + // ... + // br label %BB2 + // Don't bother merging these blocks. SinglePred and BB are dead code + // and need to be deleted. + LoopHeaders.erase(SinglePred); + LVI->eraseBlock(SinglePred); + DeleteDeadBlock(SinglePred, DTU); + LoopHeaders.erase(BB); LVI->eraseBlock(BB); - return true; + DeleteDeadBlock(BB, DTU); + return true; + } + + if (BB->hasAddressTaken()) { + // If BB only has dead constant users its address isn't really taken. + // Eliminate them before the merge attempt of BB into SinglePred. + BlockAddress *BA = BlockAddress::get(BB); + BA->removeDeadConstantUsers(); + } + + if (MergeBlockIntoPredecessor(BB, DTU)) { + // NOTE: BB is still valid when DTU uses the Lazy update strategy. + // In Lazy mode BB isn't really deleted until the DTU class is issued + // a flush() event. + + // If BB was a loop header, SinglePred becomes one. + if (LoopHeaders.erase(BB)) + LoopHeaders.insert(SinglePred); + + // Invalidate LVI for BB: the block has been merged into SinglePred. + LVI->eraseBlock(BB); + + // The LVI metadata associated with the newly merged SinglePred may not + // be valid in cases where execution is not guaranteed to follow to all + // successors in the new SinglePred. For example: + // SinglePred: ; LVI_SinglePred for value %p + // %y = use of %p + // ... + // br label %BB + // BB: ; LVI_BB for value %p + // ... + // call @exit() ; May not transfer execution to successor. + // %x = use of %p + // This merges into: + // SinglePred: ; LVI_SinglePred for value %p + // %y = use of %p + // ... + // call @exit() ; May not transfer execution to successor. + // %x = use of %p + // The LVI_SinglePred data is no longer sufficient for value %p. + if (!isGuaranteedToTransferExecutionToSuccessor(SinglePred)) + LVI->eraseBlock(SinglePred); + + return true; + } } } diff --git a/llvm/test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll b/llvm/test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll --- a/llvm/test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll +++ b/llvm/test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll @@ -15,19 +15,19 @@ ; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined br label %loop -; CHECK-LABEL: backedge: +; CHECK-LABEL: loop: ; CHECK-NEXT: ; LatticeVal for: 'i32 %a' is: overdefined ; CHECK-NEXT: ; LatticeVal for: 'i32 %length' is: overdefined -; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%backedge' is: constantrange<0, 400> -; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]' in BB: '%exit' is: constantrange<399, 400> -; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ] -; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%backedge' is: constantrange<1, 401> +; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]' in BB: '%loop' is: constantrange<-2147483648, 400> +; CHECK-NEXT: ; LatticeVal for: ' %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]' in BB: '%exit' is: constantrange<399, 400> +; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%loop' is: constantrange<-2147483647, 401> ; CHECK-NEXT: ; LatticeVal for: ' %iv.next = add nsw i32 %iv, 1' in BB: '%exit' is: constantrange<400, 401> ; CHECK-NEXT: %iv.next = add nsw i32 %iv, 1 -; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%backedge' is: overdefined +; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%loop' is: overdefined ; CHECK-NEXT: ; LatticeVal for: ' %cont = icmp slt i32 %iv.next, 400' in BB: '%exit' is: constantrange<0, -1> ; CHECK-NEXT: %cont = icmp slt i32 %iv.next, 400 -; CHECK-NOT: loop +; CHECK-NOT: backedge loop: %iv = phi i32 [0, %entry], [%iv.next, %backedge] %cnd = icmp sge i32 %iv, 0 @@ -109,7 +109,7 @@ ; CHECK-LABEL: entry ; CHECK: ; LatticeVal for: 'i32 %i' is: overdefined ; CHECK: %c = icmp ne i32 %i, -2134 -; CHECK: br i1 %c, label %cont, label %exit +; CHECK: br i1 %c, label %do, label %exit entry: %c = icmp ne i32 %i, -2134 br i1 %c, label %do, label %exit @@ -118,12 +118,12 @@ %c1 = icmp ne i32 %i, -42 br i1 %c1, label %exit2, label %exit -; CHECK-LABEL: cont: +; CHECK-LABEL: do: ; Here cont is merged to do and i is any value except -2134. ; i is not the single value: zero. ; CHECK-NOT: ; LatticeVal for: 'i32 %i' is: constantrange<0, 1> ; CHECK: ; LatticeVal for: 'i32 %i' is: constantrange<-2133, -2134> -; CHECK: ; LatticeVal for: ' %cond.0 = icmp sgt i32 %i, 0' in BB: '%cont' is: overdefined +; CHECK: ; LatticeVal for: ' %cond.0 = icmp sgt i32 %i, 0' in BB: '%do' is: overdefined ; CHECK: %cond.0 = icmp sgt i32 %i, 0 ; CHECK: %consume = call i32 @consume ; CHECK: %cond = icmp eq i32 %i, 0 diff --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll --- a/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll +++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll @@ -10,8 +10,8 @@ ;CHECK-LABEL: Top.split: ;CHECK: call void @callee(%struct.bitmap* null, %struct.bitmap* null, %struct.bitmap* %b_elt, i1 false) ;CHECK-LABEL: NextCond: -;CHECK: br {{.*}} label %callee.exit -;CHECK-LABEL: callee.exit: +;CHECK: br {{.*}} label %Cond.i +;CHECK-LABEL: Cond.i: ;CHECK: call void @dummy2(%struct.bitmap* %a_elt) define void @caller(i1 %c, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt) { diff --git a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll b/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll --- a/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll +++ b/llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll @@ -2,13 +2,13 @@ @a = external global i16, align 1 ; CHECK-LABEL: f -; CHECK: bb6: -; CHECK: bb2: +; CHECK: bb0: ; CHECK: bb3: -; CHECK-NOT: bb0: +; CHECK: bb4: ; CHECK-NOT: bb1: -; CHECK-NOT: bb4: +; CHECK-NOT: bb2: ; CHECK-NOT: bb5: +; CHECK-NOT: bb6: define void @f(i32 %p1) { bb0: %0 = icmp eq i32 %p1, 0 diff --git a/llvm/test/Transforms/JumpThreading/and-and-cond.ll b/llvm/test/Transforms/JumpThreading/and-and-cond.ll --- a/llvm/test/Transforms/JumpThreading/and-and-cond.ll +++ b/llvm/test/Transforms/JumpThreading/and-and-cond.ll @@ -8,20 +8,21 @@ ; CHECK: test br i1 %cond, label %T1, label %F1 -; CHECK-NOT: T1: T1: +; CHECK: T1: +; CHECK: %v1 = call i32 @f1() +; CHECK-NEXT: %D = and i1 %cond2, %cond3 +; CHECK-NEXT: br i1 %D %v1 = call i32 @f1() br label %Merge +; CHECK-NOT: Merge: + F1: %v2 = call i32 @f2() br label %Merge Merge: -; CHECK: Merge: -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: %D = and i1 %cond2, %cond3 -; CHECK-NEXT: br i1 %D %A = phi i1 [true, %T1], [false, %F1] %B = phi i32 [%v1, %T1], [%v2, %F1] %C = and i1 %A, %cond2 diff --git a/llvm/test/Transforms/JumpThreading/and-cond.ll b/llvm/test/Transforms/JumpThreading/and-cond.ll --- a/llvm/test/Transforms/JumpThreading/and-cond.ll +++ b/llvm/test/Transforms/JumpThreading/and-cond.ll @@ -8,19 +8,20 @@ ; CHECK: test br i1 %cond, label %T1, label %F1 -; CHECK-NOT: T1 T1: +; CHECK: T1: +; CHECK: %v1 = call i32 @f1() +; CHECK-NEXT: br i1 %cond2 %v1 = call i32 @f1() br label %Merge +; CHECK-NOT: Merge + F1: %v2 = call i32 @f2() br label %Merge Merge: -; CHECK: Merge: -; CHECK: %v1 = call i32 @f1() -; CHECK-NEXT: br i1 %cond2 %A = phi i1 [true, %T1], [false, %F1] %B = phi i32 [%v1, %T1], [%v2, %F1] %C = and i1 %A, %cond2 diff --git a/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll b/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll --- a/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll +++ b/llvm/test/Transforms/JumpThreading/assume-edge-dom.ll @@ -8,7 +8,7 @@ br i1 %cond, label %taken, label %not_taken ; CHECK-LABEL: @test1 -; CHECK: br i1 %cond, label %no, label %yes +; CHECK: br i1 %cond, label %taken, label %not_taken ; CHECK: ret i1 true taken: diff --git a/llvm/test/Transforms/JumpThreading/basic.ll b/llvm/test/Transforms/JumpThreading/basic.ll --- a/llvm/test/Transforms/JumpThreading/basic.ll +++ b/llvm/test/Transforms/JumpThreading/basic.ll @@ -23,13 +23,13 @@ br i1 %A, label %T2, label %F2 T2: -; CHECK: T2: +; CHECK: T1: ; CHECK: ret i32 %v1 call void @f3() ret i32 %B F2: -; CHECK: F2: +; CHECK: F1: ; CHECK: ret i32 %v2 ret i32 %B } @@ -148,15 +148,15 @@ %tmp455 = icmp eq i32 %A, 42 br i1 %tmp455, label %BB1, label %BB2 -; CHECK: call i32 @f2() -; CHECK-NEXT: ret i32 3 - ; CHECK: call i32 @f1() ; CHECK-NOT: br ; CHECK: call void @f3() ; CHECK-NOT: br ; CHECK: ret i32 4 +; CHECK: call i32 @f2() +; CHECK-NEXT: ret i32 3 + BB2: call i32 @f1() br label %BB1 @@ -195,7 +195,7 @@ %O = and i1 %M, %N br i1 %O, label %T2, label %F2 -; CHECK: Merge: +; CHECK: F1: ; CHECK-NOT: phi ; CHECK-NEXT: %v2 = call i32 @f2() @@ -220,7 +220,7 @@ ; CHECK: T0: ; CHECK-NEXT: call -; CHECK-NEXT: br i1 %A, label %T1, label %Y +; CHECK-NEXT: br i1 %A, label %T1, label %F1 T1: %B = call i1 @test8a() @@ -228,14 +228,14 @@ ; CHECK: T1: ; CHECK-NEXT: call -; CHECK-NEXT: br i1 %B, label %T2, label %Y +; CHECK-NEXT: br i1 %B, label %T2, label %F1 T2: %C = call i1 @test8a() br i1 %cond, label %T3, label %F1 ; CHECK: T2: ; CHECK-NEXT: call -; CHECK-NEXT: br i1 %cond, label %T3, label %Y +; CHECK-NEXT: br i1 %cond, label %T3, label %F1 T3: ret i32 0 @@ -261,7 +261,7 @@ ; CHECK: Entry: ; CHECK-NEXT: %v1 = call i32 @f1() -; CHECK-NEXT: br i1 %cond, label %F2, label %Merge +; CHECK-NEXT: br i1 %cond, label %F2, label %F1 F1: %v2 = call i32 @f2() @@ -275,7 +275,7 @@ %O = and i1 %M1, %N br i1 %O, label %T2, label %F2 -; CHECK: Merge: +; CHECK: F1: ; CHECK-NOT: phi ; CHECK-NEXT: %v2 = call i32 @f2() @@ -299,7 +299,7 @@ ;; Non-local condition threading. define i32 @test10g(i1 %cond) { ; CHECK-LABEL: @test10g( -; CHECK-NEXT: br i1 %cond, label %T2, label %F2 +; CHECK-NEXT: br i1 %cond, label %T1, label %F1 br i1 %cond, label %T1, label %F1 T1: @@ -364,7 +364,7 @@ ; Should branch to the return block instead of through BB1. ; CHECK: entry: ; CHECK-NEXT: %cond = icmp eq i32 %A, 0 -; CHECK-NEXT: br i1 %cond, label %bb1, label %return +; CHECK-NEXT: br i1 %cond, label %bb, label %return bb: %B = call i32 @test10f2() @@ -375,7 +375,7 @@ %cond4 = icmp eq i32 %C, 0 br i1 %cond4, label %bb2, label %return -; CHECK: bb1: +; CHECK: bb: ; CHECK-NEXT: %B = call i32 @test10f2() ; CHECK-NEXT: %cond4 = icmp eq i32 %B, 0 ; CHECK-NEXT: br i1 %cond4, label %bb2, label %return @@ -413,9 +413,9 @@ F2: ret i32 %v1 -; CHECK: br i1 %cond, label %F2, label %Merge +; CHECK: br i1 %cond, label %F2, label %F1 -; CHECK: Merge: +; CHECK: F1: ; CHECK-NEXT: %M = icmp eq i32 %v1, 192 ; CHECK-NEXT: %N = xor i1 %cond2, %M ; CHECK-NEXT: br i1 %N, label %T2, label %F2 @@ -425,14 +425,15 @@ define i32 @test14(i32 %in) { entry: %A = icmp eq i32 %in, 0 -; CHECK: br i1 %A, label %right_ret, label %merge +; CHECK: br i1 %A, label %right_ret, label %right br i1 %A, label %left, label %right +; CHECK-NOT: merge: + ; CHECK-NOT: left: left: br label %merge -; CHECK-NOT: right: right: %B = call i32 @f1() br label %merge @@ -483,7 +484,7 @@ br i1 %cond, label %Merge, label %F1 ; CHECK: Entry: -; CHECK-NEXT: br i1 %cond, label %F2, label %Merge +; CHECK-NEXT: br i1 %cond, label %F2, label %F1 F1: %v1 = call i32 @f1() @@ -496,7 +497,7 @@ %N = icmp eq i32 %M1, 0 br i1 %N, label %T2, label %F2 -; CHECK: Merge: +; CHECK: F1: ; CHECK-NOT: phi ; CHECK-NEXT: %v1 = call i32 @f1() diff --git a/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll b/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll --- a/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll +++ b/llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll @@ -1,6 +1,6 @@ ; RUN: opt -S < %s -jump-threading | FileCheck %s ; CHECK-LABEL: @foo -; CHECK-NEXT: exit2: +; CHECK-NEXT: entry: ; CHECK-NEXT: ret void define void @foo() { entry: diff --git a/llvm/test/Transforms/JumpThreading/combine-metadata.ll b/llvm/test/Transforms/JumpThreading/combine-metadata.ll --- a/llvm/test/Transforms/JumpThreading/combine-metadata.ll +++ b/llvm/test/Transforms/JumpThreading/combine-metadata.ll @@ -8,14 +8,14 @@ ; Check that we propagate nonnull to dominated loads, when we find an available ; loaded value. ; CHECK-LABEL: @test1( -; CHECK-LABEL: ret1: +; CHECK-LABEL: d3.thread: ; CHECK-NEXT: %[[p1:.*]] = load i32*, i32** %ptr ; CHECK-NOT: !nonnull ; CHECK-NEXT: store i32 1, i32* %[[p1]] ; CHECK-NEXT: tail call void @use(i32* null) ; CHECK-NEXT: ret void -; CHECK-LABEL: ret2: +; CHECK-LABEL: d1: ; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, !nonnull !0 ; CHECK: tail call void @use(i32* %[[p2]]) ; CHECK-NEXT: ret void @@ -53,7 +53,7 @@ ; CHECK-NEXT: store i32 1, i32* %[[p1]] ; CHECK-NEXT: br label %ret1 -; CHECK-LABEL: d3: +; CHECK-LABEL: d1: ; CHECK-NEXT: %[[p_cmp:.*]] = load i32*, i32** %ptr ; CHECK-NEXT: %[[p2:.*]] = load i32*, i32** %ptr, !nonnull !0 ; CHECK-NEXT: store i32 1, i32* %[[p2]] diff --git a/llvm/test/Transforms/JumpThreading/fold-not-thread.ll b/llvm/test/Transforms/JumpThreading/fold-not-thread.ll --- a/llvm/test/Transforms/JumpThreading/fold-not-thread.ll +++ b/llvm/test/Transforms/JumpThreading/fold-not-thread.ll @@ -48,7 +48,7 @@ ; L0 is too big to duplicate. L2 is the unreachable block here. ; ; CHECK-LABEL: @test_br_folding_not_threading( -; CHECK: L1: +; CHECK: L0: ; CHECK: call i32 @f2() ; CHECK: call void @f3() ; CHECK-NEXT: ret void @@ -90,7 +90,7 @@ ; With more than 1 predecessors. ; ; CHECK-LABEL: @test_br_folding_not_threading_multiple_preds( -; CHECK: L1: +; CHECK: L0: ; CHECK: call i32 @f2() ; CHECK: call void @f3() ; CHECK-NEXT: ret void @@ -197,7 +197,7 @@ ; L2 is the unreachable block here. ; ; CHECK-LABEL: @test_br_folding_not_threading_indirect_branch( -; CHECK: L1: +; CHECK: L0: ; CHECK: call i32 @f2() ; CHECK: call void @f3() ; CHECK-NEXT: ret void diff --git a/llvm/test/Transforms/JumpThreading/guards.ll b/llvm/test/Transforms/JumpThreading/guards.ll --- a/llvm/test/Transforms/JumpThreading/guards.ll +++ b/llvm/test/Transforms/JumpThreading/guards.ll @@ -11,7 +11,7 @@ br i1 %cond, label %T1, label %F1 T1: -; CHECK: T1.split +; CHECK: T1 ; CHECK: %v1 = call i32 @f1() ; CHECK-NEXT: %retVal ; CHECK-NEXT: br label %Merge @@ -19,7 +19,7 @@ br label %Merge F1: -; CHECK: F1.split +; CHECK: F1 ; CHECK: %v2 = call i32 @f2() ; CHECK-NEXT: %retVal ; CHECK-NEXT: %condGuard @@ -44,7 +44,7 @@ br i1 %cond, label %T1, label %F1 T1: -; CHECK: T1.split: +; CHECK: T1: ; CHECK-NEXT: %v1 = call i32 @f1() ; CHECK-NEXT: %retVal ; CHECK-NEXT: %condGuard @@ -54,7 +54,7 @@ br label %Merge F1: -; CHECK: F1.split: +; CHECK: F1: ; CHECK-NEXT: %v2 = call i32 @f2() ; CHECK-NEXT: %retVal ; CHECK-NEXT: br label %Merge @@ -165,7 +165,7 @@ ret void Pred: -; CHECK-NEXT: Pred: +; CHECK-NEXT: Parent: ; CHECK-NEXT: switch i32 %a, label %Exit switch i32 %a, label %Exit [ i32 10, label %Merge @@ -253,7 +253,7 @@ ; triggers source code `ProcessThreadableEdges`. define void @dont_fold_guard4(i1 %cmp1, i32 %i) nounwind { ; CHECK-LABEL: dont_fold_guard4 -; CHECK-LABEL: L2: +; CHECK-LABEL: L0: ; CHECK-NEXT: %cmp = icmp eq i32 %i, 0 ; CHECK-NEXT: guard(i1 %cmp) ; CHECK-NEXT: dummy(i1 true) diff --git a/llvm/test/Transforms/JumpThreading/header-succ.ll b/llvm/test/Transforms/JumpThreading/header-succ.ll --- a/llvm/test/Transforms/JumpThreading/header-succ.ll +++ b/llvm/test/Transforms/JumpThreading/header-succ.ll @@ -15,7 +15,7 @@ %ind = phi i32 [0, %top], [%nextind, %latch] %nextind = add i32 %ind, 1 %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %latch, label %exit +; CHECK: br i1 %cmp, label %body, label %exit br i1 %cmp, label %body, label %latch body: @@ -49,7 +49,7 @@ %ind = phi i32 [0, %top], [%nextind, %latch] %nextind = add i32 %ind, 1 %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %exit, label %latch +; CHECK: br i1 %cmp, label %body, label %latch br i1 %cmp, label %body, label %latch body: @@ -81,7 +81,7 @@ %ind = phi i32 [0, %top], [%nextind, %latch] %nextind = add i32 %ind, 1 %cmp = icmp ule i32 %ind, 10 -; CHECK: br i1 %cmp, label %latch, label %exit +; CHECK: br i1 %cmp, label %body, label %exit br i1 %cmp, label %body, label %latch body: diff --git a/llvm/test/Transforms/JumpThreading/implied-cond.ll b/llvm/test/Transforms/JumpThreading/implied-cond.ll --- a/llvm/test/Transforms/JumpThreading/implied-cond.ll +++ b/llvm/test/Transforms/JumpThreading/implied-cond.ll @@ -12,9 +12,9 @@ left: ; CHECK: entry: -; CHECK: br i1 %c0, label %left0, label %right +; CHECK: br i1 %c0, label %left, label %right -; CHECK: left0: +; CHECK: left: ; CHECK: call void @side_effect ; CHECK-NOT: br i1 %c1 ; CHECK: call void @side_effect @@ -42,9 +42,9 @@ left: ; CHECK: entry: -; CHECK: br i1 %c0, label %left0, label %right +; CHECK: br i1 %c0, label %left, label %right -; CHECK: left0: +; CHECK: left: ; CHECK: call void @side_effect ; CHECK-NOT: br i1 %c1 ; CHECK: call void @side_effect @@ -68,8 +68,8 @@ ; CHECK: entry: ; CHECK: br i1 %c0, label %cont, label %right ; CHECK: cont: -; CHECK: br i1 %c, label %left0, label %right -; CHECK: left0: +; CHECK: br i1 %c, label %left, label %right +; CHECK: left: ; CHECK: call void @side_effect(i32 0) ; CHECK: call void @side_effect(i32 0) entry: @@ -100,7 +100,7 @@ ; A s<= B implies A s> B is false. ; CHECK-LABEL: @test3( ; CHECK: entry: -; CHECK: br i1 %cmp, label %if.end, label %if.end3 +; CHECK: br i1 %cmp, label %if.then, label %if.end3 ; CHECK-NOT: br i1 %cmp1, label %if.then2, label %if.end ; CHECK-NOT: call void @side_effect(i32 0) ; CHECK: br label %if.end3 diff --git a/llvm/test/Transforms/JumpThreading/indirectbr.ll b/llvm/test/Transforms/JumpThreading/indirectbr.ll --- a/llvm/test/Transforms/JumpThreading/indirectbr.ll +++ b/llvm/test/Transforms/JumpThreading/indirectbr.ll @@ -14,10 +14,10 @@ ; Check basic jump threading for indirectbr instructions. ; CHECK: void @test1 -; CHECK: br i1 %tobool, label %L1, label %indirectgoto -; CHECK-NOT: if.else: -; CHECK: L1: +; CHECK: br i1 %tobool, label %L1, label %if.else ; CHECK: indirectbr i8* %address, [label %L1, label %L2] +; CHECK: L1: +; CHECK-NOT: indirectgoto: define void @test1(i32 %i, i8* %address) nounwind { entry: %rem = srem i32 %i, 2 diff --git a/llvm/test/Transforms/JumpThreading/induction.ll b/llvm/test/Transforms/JumpThreading/induction.ll --- a/llvm/test/Transforms/JumpThreading/induction.ll +++ b/llvm/test/Transforms/JumpThreading/induction.ll @@ -3,13 +3,13 @@ define i8 @test(i32 %a, i32 %length) { ; CHECK-LABEL: @test entry: -; CHECK: br label %backedge +; CHECK: br label %loop br label %loop loop: -; CHECK-LABEL: backedge: +; CHECK-LABEL: loop: ; CHECK: phi i32 -; CHECK: br i1 %cont, label %backedge, label %exit +; CHECK: br i1 %cont, label %loop, label %exit %iv = phi i32 [0, %entry], [%iv.next, %backedge] ;; We can use an inductive argument to prove %iv is always positive %cnd = icmp sge i32 %iv, 0 diff --git a/llvm/test/Transforms/JumpThreading/lvi-tristate.ll b/llvm/test/Transforms/JumpThreading/lvi-tristate.ll --- a/llvm/test/Transforms/JumpThreading/lvi-tristate.ll +++ b/llvm/test/Transforms/JumpThreading/lvi-tristate.ll @@ -1,5 +1,5 @@ ; RUN: opt -jump-threading -simplifycfg -S < %s | FileCheck %s -; CHECK-NOT: bb6: +; CHECK-NOT: bb10: ; CHECK-NOT: bb7: ; CHECK-NOT: bb8: ; CHECK-NOT: bb11: @@ -7,7 +7,7 @@ ; CHECK: bb: ; CHECK: bb2: ; CHECK: bb4: -; CHECK: bb10: +; CHECK: bb6: ; CHECK: bb13: declare void @ham() diff --git a/llvm/test/Transforms/JumpThreading/phi-known.ll b/llvm/test/Transforms/JumpThreading/phi-known.ll --- a/llvm/test/Transforms/JumpThreading/phi-known.ll +++ b/llvm/test/Transforms/JumpThreading/phi-known.ll @@ -29,13 +29,13 @@ %cmp1 = icmp eq i8* %p1, null br i1 %cmp1, label %exit, label %backedge backedge: -; CHECK-LABEL: backedge: +; CHECK-LABEL: loop: ; CHECK-NEXT: phi ; CHECK-NEXT: bitcast ; CHECK-NEXT: load ; CHECK-NEXT: cmp ; CHECK-NEXT: br -; CHECK-DAG: label %backedge +; CHECK-DAG: label %loop %addr = bitcast i8* %p1 to i8** %p2 = load i8*, i8** %addr %cmp2 = icmp eq i8* %p2, null diff --git a/llvm/test/Transforms/JumpThreading/range-compare.ll b/llvm/test/Transforms/JumpThreading/range-compare.ll --- a/llvm/test/Transforms/JumpThreading/range-compare.ll +++ b/llvm/test/Transforms/JumpThreading/range-compare.ll @@ -11,7 +11,7 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], 9 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_END_THREAD:%.*]], label [[IF_END:%.*]] -; CHECK: if.end.thread: +; CHECK: if.then: ; CHECK-NEXT: call void (...) @bar() ; CHECK-NEXT: br label [[IF_END4:%.*]] ; CHECK: if.end: @@ -51,7 +51,7 @@ ; CHECK-NEXT: entry: ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 9 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_END4:%.*]] -; CHECK: if.end: +; CHECK: if.then: ; CHECK-NEXT: call void (...) @bar() ; CHECK-NEXT: [[X_OFF:%.*]] = add i32 [[X]], -3 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X_OFF]], 5 diff --git a/llvm/test/Transforms/JumpThreading/removed-use.ll b/llvm/test/Transforms/JumpThreading/removed-use.ll --- a/llvm/test/Transforms/JumpThreading/removed-use.ll +++ b/llvm/test/Transforms/JumpThreading/removed-use.ll @@ -1,9 +1,9 @@ ; RUN: opt -S < %s -jump-threading | FileCheck %s ; CHECK-LABEL: @foo -; CHECK: bb6: +; CHECK: entry: ; CHECK-NEXT: ret void -; CHECK: bb3: -; CHECK: br label %bb3 +; CHECK: bb5: +; CHECK: br label %bb5 define void @foo() { entry: br i1 true, label %bb6, label %bb3 diff --git a/llvm/test/Transforms/JumpThreading/select.ll b/llvm/test/Transforms/JumpThreading/select.ll --- a/llvm/test/Transforms/JumpThreading/select.ll +++ b/llvm/test/Transforms/JumpThreading/select.ll @@ -97,7 +97,7 @@ ; CHECK-LABEL: @test_indirectbr_thresh( ; CHECK-NEXT: entry: -; CHECK-NEXT: br i1 %cond, label %L1, label %L3 +; CHECK-NEXT: br i1 %cond, label %L0, label %L3 ; CHECK-NOT: indirectbr define void @test_indirectbr_thresh(i1 %cond, i8* %address) nounwind { entry: @@ -284,7 +284,7 @@ ; CHECK: br i1 %cmp.i, label %.exit.thread2, label %cond.false.i ; CHECK: br i1 %cmp4.i, label %.exit.thread, label %cond.false.6.i ; CHECK: br i1 %cmp8.i, label %.exit.thread2, label %cond.false.10.i -; CHECK: br i1 %cmp13.i, label %.exit.thread, label %.exit +; CHECK: br i1 %cmp13.i, label %.exit.thread, label %cond.false.15.i ; CHECK: br i1 %phitmp, label %.exit.thread, label %.exit.thread2 ; CHECK: br label %.exit.thread2 } @@ -322,7 +322,7 @@ ; CHECK: br i1 %cmp.i, label %.exit.thread, label %cond.false.i ; CHECK: br i1 %cmp4.i, label %.exit.thread3, label %cond.false.6.i ; CHECK: br i1 %cmp8.i, label %.exit.thread, label %cond.false.10.i -; CHECK: br i1 %cmp13.i, label %.exit.thread3, label %.exit +; CHECK: br i1 %cmp13.i, label %.exit.thread3, label %cond.false.15.i ; CHECK: br i1 %lnot.i18, label %.exit.thread, label %.exit.thread3 ; CHECK: br label %.exit.thread3 } diff --git a/llvm/test/Transforms/JumpThreading/static-profile.ll b/llvm/test/Transforms/JumpThreading/static-profile.ll --- a/llvm/test/Transforms/JumpThreading/static-profile.ll +++ b/llvm/test/Transforms/JumpThreading/static-profile.ll @@ -84,13 +84,13 @@ %cond1 = icmp eq i32 %v, 1 br i1 %cond1, label %eq_1, label %check_2 ; No metadata: -; CHECK: br i1 %cond1, label %check_2.thread, label %check_2{{$}} +; CHECK: br i1 %cond1, label %eq_1, label %check_2{{$}} eq_1: call void @bar() br label %check_2 ; Verify the new edge: -; CHECK: check_2.thread: +; CHECK: eq_1: ; CHECK-NEXT: call void @bar() ; CHECK-NEXT: br label %latch diff --git a/llvm/test/Transforms/JumpThreading/thread-loads.ll b/llvm/test/Transforms/JumpThreading/thread-loads.ll --- a/llvm/test/Transforms/JumpThreading/thread-loads.ll +++ b/llvm/test/Transforms/JumpThreading/thread-loads.ll @@ -14,7 +14,7 @@ br i1 %1, label %bb1, label %bb bb: ; preds = %entry -; CHECK: bb1.thread: +; CHECK: bb: ; CHECK: store ; CHECK: br label %bb3 store i32 42, i32* %P, align 4 @@ -32,7 +32,7 @@ bb3: ; preds = %bb1 ; CHECK: bb3: -; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ] +; CHECK: %res.01 = phi i32 [ 1, %bb ], [ 0, %bb1thread-pre-split ] ; CHECK: ret i32 %res.01 ret i32 %res.0 } @@ -53,7 +53,7 @@ br i1 %1, label %bb1, label %bb bb: ; preds = %entry -; CHECK: bb1.thread: +; CHECK: bb: ; CHECK: store{{.*}}, !tbaa !0 ; CHECK: br label %bb3 store i32 42, i32* %P, align 4, !tbaa !0 @@ -71,7 +71,7 @@ bb3: ; preds = %bb1 ; CHECK: bb3: -; CHECK: %res.01 = phi i32 [ 1, %bb1.thread ], [ 0, %bb1 ] +; CHECK: %res.01 = phi i32 [ 1, %bb ], [ 0, %bb1thread-pre-split ] ; CHECK: ret i32 %res.01 ret i32 %res.0 } @@ -115,14 +115,14 @@ br i1 %v1, label %bb1, label %bb bb: -; CHECK: bb1.thread: +; CHECK: bb: ; CHECK: store atomic ; CHECK: br label %bb3 store atomic i32 42, i32* %P unordered, align 4 br label %bb1 bb1: -; CHECK: bb1: +; CHECK: bb1thread-pre-split: ; CHECK-NOT: phi ; CHECK: load atomic %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] @@ -309,10 +309,10 @@ ; CHECK-LABEL: cond1: ; CHECK: %[[LD1:.*]] = load i64, i64* %P ; CHECK: br i1 %c, label %[[THREAD:.*]], label %end -; CHECK-LABEL: cond2: +; CHECK-LABEL: cond2thread-pre-split: ; CHECK: %[[LD2:.*]] = load i64, i64* %P ; CHECK-LABEL: cond3: -; CHECK: %[[PHI:.*]] = phi i64 [ %[[LD1]], %[[THREAD]] ], [ %[[LD2]], %cond2 ] +; CHECK: %[[PHI:.*]] = phi i64 [ %[[LD1]], %[[THREAD]] ], [ %[[LD2]], %cond2thread-pre-split ] ; CHECK: call void @fn3(i64 %[[PHI]]) entry: br i1 %c2, label %cond2, label %cond1 @@ -354,7 +354,7 @@ ; CHECK: br i1 %[[C1]], label %sw.bb21.i.thread, label %if.then.i64 ; CHECK-LABEL: sw.bb21.i.thread: ; CHECK: br label %[[THREAD_TO:.*]] -; CHECK-LABEL: sw.bb21.i: +; CHECK-LABEL: sw.bb21.ithread-pre-split: ; CHECK: %[[LD2:.*]] = load i32, i32* %arrayidx185, align 4 ; CHECK: %[[C2:.*]] = icmp eq i32 %[[LD2]], 0 ; CHECK:br i1 %[[C2]], label %[[THREAD_TO]], label %cleanup @@ -417,15 +417,15 @@ ; CHECK-LABEL: @fn_SinglePred ; CHECK-LABEL: entry: ; CHECK: %[[L1:.*]] = load i64, i64* %P -; CHECK: br i1 %c, label %cond3, label %cond1 +; CHECK: br i1 %c, label %cond2.thread, label %cond1 +; CHECK-LABEL: cond2.thread: +; CHECK: call void @fn2(i64 %l1) +; CHECK: call void @fn3(i64 %l1) ; CHECK-LABEL: cond2: ; CHECK-NOT: load ; CHECK: %[[PHI:.*]] = phi i64 [ %[[L1]], %cond1 ] ; CHECK: call void @fn2(i64 %[[PHI]]) ; CHECK: br label %end -; CHECK-LABEL: cond3: -; CHECK: call void @fn2(i64 %l1) -; CHECK: call void @fn3(i64 %l1) entry: %l1 = load i64, i64* %P @@ -453,15 +453,15 @@ ; CHECK-LABEL: @fn_SinglePredMultihop ; CHECK-LABEL: entry: ; CHECK: %[[L1:.*]] = load i64, i64* %P -; CHECK: br i1 %c0, label %cond3, label %cond0 +; CHECK: br i1 %c0, label %cond2.thread, label %cond0 +; CHECK-LABEL: cond2.thread: +; CHECK: call void @fn2(i64 %l1) +; CHECK: call void @fn3(i64 %l1) ; CHECK-LABEL: cond2: ; CHECK-NOT: load ; CHECK: %[[PHI:.*]] = phi i64 [ %[[L1]], %cond1 ] ; CHECK: call void @fn2(i64 %[[PHI]]) ; CHECK: br label %end -; CHECK-LABEL: cond3: -; CHECK: call void @fn2(i64 %l1) -; CHECK: call void @fn3(i64 %l1) entry: %l1 = load i64, i64* %P @@ -497,7 +497,7 @@ ; store. ; ; CHECK-LABEL: define i32 @phi_translate_partial_redundant_loads(i32, i32*, i32* -; CHECK: merge.thread: +; CHECK: left: ; CHECK: store ; CHECK: br label %left_x ; diff --git a/llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll b/llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll --- a/llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll +++ b/llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll @@ -16,7 +16,7 @@ ; CHECK: return: ; CHECK: %retval.0 = phi i32 [ %tmp7.i, %land.lhs.true ], [ 0, %do.cond ], [ %tmp7.i.1, %land.lhs.true.1 ], [ 0, %do.cond.1 ], [ %tmp7.i.2, %land.lhs.true.2 ], [ 0, %do.cond.2 ], [ %tmp7.i.3, %land.lhs.true.3 ], [ 0, %do.cond.3 ] ; CHECK-NOT: @bar( -; CHECK: bar.exit.3 +; CHECK: cond.true.i.3 define i32 @foo() uwtable ssp align 2 { entry: br i1 undef, label %return, label %if.end diff --git a/llvm/test/Transforms/NewGVN/pair_jumpthread.ll b/llvm/test/Transforms/NewGVN/pair_jumpthread.ll --- a/llvm/test/Transforms/NewGVN/pair_jumpthread.ll +++ b/llvm/test/Transforms/NewGVN/pair_jumpthread.ll @@ -21,7 +21,7 @@ ; CHECK: [[TOBOOL:%.*]] = icmp eq i64 [[PHIOFOPS]], 0 ; ; CHECK-JT-LABEL: @testBI( -; CHECK-JT: _ZL6calleei.exit.thread: +; CHECK-JT: if.then.i: ; entry: @@ -80,7 +80,7 @@ ; CHECK: [[TOBOOL:%.*]] = icmp eq i64 [[PHIOFOPS]], 0 ; ; CHECK-JT-LABEL: @testIB( -; CHECK-JT: _ZL6calleei.exit.thread: +; CHECK-JT: if.then.i: ; entry: diff --git a/llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll b/llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll --- a/llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll +++ b/llvm/test/Transforms/PhaseOrdering/simplifycfg-options.ll @@ -7,7 +7,7 @@ define i1 @PR33605(i32 %a, i32 %b, i32* %c) { ; ALL-LABEL: @PR33605( -; ALL-NEXT: for.body: +; ALL-NEXT: entry: ; ALL-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]] ; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1 ; ALL-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4