SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 30 Jul 2014 21:04:00 +0000 (21:04 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 30 Jul 2014 21:04:00 +0000 (21:04 +0000)
The lifetime intrinsics need some work in order to make it clear which
optimizations are or are not valid.

For now dropping this optimization avoids a miscompilation.

Patch by Björn Steinbrink.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214336 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/lifetime.ll

index 24bb63bb60a5f8108bb1006db1715dfea44a7214..1c62559739f9bd34c7e5b73fe36510cdd3f561ce 100644 (file)
@@ -4008,7 +4008,7 @@ bool SimplifyCFGOpt::SimplifyUncondBranch(BranchInst *BI, IRBuilder<> &Builder){
     return true;
 
   // If the Terminator is the only non-phi instruction, simplify the block.
-  BasicBlock::iterator I = BB->getFirstNonPHIOrDbgOrLifetime();
+  BasicBlock::iterator I = BB->getFirstNonPHIOrDbg();
   if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
       TryToSimplifyUncondBranchFromEmptyBlock(BB))
     return true;
index b79422172530ed65afe88585fce53f8bf01827f4..7c66be5295007daa64cae3715a31fe3514d3b8fd 100644 (file)
@@ -1,11 +1,11 @@
 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
 
-; Test that a lifetime intrinsic doesn't prevent us from simplifying this.
+; Test that a lifetime intrinsic isn't removed because that would change semantics
 
 ; CHECK: foo
 ; CHECK: entry:
-; CHECK-NOT: bb0:
-; CHECK-NOT: bb1:
+; CHECK: bb0:
+; CHECK: bb1:
 ; CHECK: ret
 define void @foo(i1 %x) {
 entry: