Commit e0cba6fb authored by Tom Stellard's avatar Tom Stellard
Browse files

Merging r214336:

------------------------------------------------------------------------
r214336 | rafael.espindola | 2014-07-30 17:04:00 -0400 (Wed, 30 Jul 2014) | 9 lines

SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics.

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.

------------------------------------------------------------------------

llvm-svn: 232544
parent a3a80c71
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
+3 −3
Original line number Diff line number Diff line
; 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: