[llvm] r329660 - [SSAUpdaterBulk] Handle CFG with unreachable from entry blocks.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 9 19:16:29 PDT 2018
Author: mzolotukhin
Date: Mon Apr 9 19:16:29 2018
New Revision: 329660
URL: http://llvm.org/viewvc/llvm-project?rev=329660&view=rev
Log:
[SSAUpdaterBulk] Handle CFG with unreachable from entry blocks.
Added:
llvm/trunk/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll
Modified:
llvm/trunk/lib/Transforms/Utils/SSAUpdaterBulk.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdaterBulk.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdaterBulk.cpp?rev=329660&r1=329659&r2=329660&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SSAUpdaterBulk.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SSAUpdaterBulk.cpp Mon Apr 9 19:16:29 2018
@@ -57,7 +57,7 @@ bool SSAUpdaterBulk::HasValueForBlock(un
Value *SSAUpdaterBulk::computeValueAt(BasicBlock *BB, RewriteInfo &R,
DominatorTree *DT) {
if (!R.Defines.count(BB)) {
- if (PredCache.get(BB).size()) {
+ if (DT->isReachableFromEntry(BB) && PredCache.get(BB).size()) {
BasicBlock *IDom = DT->getNode(BB)->getIDom()->getBlock();
R.Defines[BB] = computeValueAt(IDom, R, DT);
} else
Added: llvm/trunk/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll?rev=329660&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll (added)
+++ llvm/trunk/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll Mon Apr 9 19:16:29 2018
@@ -0,0 +1,26 @@
+; RUN: opt -S < %s -jump-threading | FileCheck %s
+; CHECK-LABEL: @foo
+; CHECK-NEXT: exit2:
+; CHECK-NEXT: ret void
+define void @foo() {
+entry:
+ br label %bb1
+
+entry2:
+ br label %bb1
+
+bb1:
+ %a0 = phi i32 [ undef, %entry2 ], [ 0, %entry ]
+ %b = icmp ne i32 %a0, 0
+ br i1 %b, label %bb2, label %exit2
+
+bb2:
+ br label %exit1
+
+exit1:
+ %a1 = phi i32 [ %a0, %bb2 ]
+ ret void
+
+exit2:
+ ret void
+}
More information about the llvm-commits
mailing list