Skip to content

Commit 890090f

Browse files
committed
[MemorySSA] Check for unreachable blocks when getting last definition.
If a single predecessor is found, still check if the block is unreachable. The test that found this had a self loop unreachable block. Resolves PR43493. llvm-svn: 373383
1 parent 7ed4fb3 commit 890090f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

llvm/lib/Analysis/MemorySSAUpdater.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ void MemorySSAUpdater::applyInsertUpdates(ArrayRef<CFGUpdate> Updates,
839839
} else {
840840
// Single predecessor, BB cannot be dead. GetLastDef of Pred.
841841
assert(Count == 1 && Pred && "Single predecessor expected.");
842+
// BB can be unreachable though, return LoE if that is the case.
843+
if (!DT.getNode(BB))
844+
return MSSA->getLiveOnEntryDef();
842845
BB = Pred;
843846
}
844847
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: opt -enable-mssa-loop-dependency=true -loop-rotate -verify-memoryssa -S %s | FileCheck %s
2+
; REQUIRES: asserts
3+
4+
; CHECK-LABEL: @func_35()
5+
define void @func_35() {
6+
entry:
7+
br i1 undef, label %for.cond1704.preheader, label %return
8+
9+
for.cond1704.preheader: ; preds = %entry
10+
br label %for.cond1704
11+
12+
for.cond1704: ; preds = %for.cond1704.preheader, %for.body1707
13+
br i1 false, label %for.body1707, label %return.loopexit
14+
15+
for.body1707: ; preds = %for.cond1704
16+
store i32 1712, i32* undef, align 1
17+
br label %for.cond1704
18+
19+
for.body1102: ; preds = %for.body1102
20+
br i1 undef, label %for.body1102, label %return
21+
22+
return.loopexit: ; preds = %for.cond1704
23+
br label %return
24+
25+
return: ; preds = %return.loopexit, %for.body1102, %entry
26+
ret void
27+
}

0 commit comments

Comments
 (0)