Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

SimplifyCFG: Avoid miscompilations due to removed lifetime intrinsics #19

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4011,7 +4011,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;
Expand Down
6 changes: 3 additions & 3 deletions test/Transforms/SimplifyCFG/lifetime.ll
Original file line number Diff line number Diff line change
@@ -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:
Expand Down