[llvm] r360796 - [PredicateInfo] Do not process unreachable operands.
Taewook Oh via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 12:35:38 PDT 2019
Author: twoh
Date: Wed May 15 12:35:38 2019
New Revision: 360796
URL: http://llvm.org/viewvc/llvm-project?rev=360796&view=rev
Log:
[PredicateInfo] Do not process unreachable operands.
Summary: We should excluded unreachable operands from processing as their DFS visitation order is undefined. When `renameUses` function sorts `OpsToRename` (https://fburl.com/d2wubn60), the comparator assumes that the parent block of the operand has a corresponding dominator tree node. This is not the case for unreachable operands and crashes the compiler.
Reviewers: dberlin, mgrang, davide
Subscribers: efriedma, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61154
Added:
llvm/trunk/test/Transforms/Util/PredicateInfo/unreachable.ll
Modified:
llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp
Modified: llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp?rev=360796&r1=360795&r2=360796&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp Wed May 15 12:35:38 2019
@@ -473,7 +473,8 @@ void PredicateInfo::buildPredicateInfo()
}
for (auto &Assume : AC.assumptions()) {
if (auto *II = dyn_cast_or_null<IntrinsicInst>(Assume))
- processAssume(II, II->getParent(), OpsToRename);
+ if (DT.isReachableFromEntry(II->getParent()))
+ processAssume(II, II->getParent(), OpsToRename);
}
// Now rename all our operations.
renameUses(OpsToRename);
Added: llvm/trunk/test/Transforms/Util/PredicateInfo/unreachable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Util/PredicateInfo/unreachable.ll?rev=360796&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Util/PredicateInfo/unreachable.ll (added)
+++ llvm/trunk/test/Transforms/Util/PredicateInfo/unreachable.ll Wed May 15 12:35:38 2019
@@ -0,0 +1,25 @@
+; RUN: opt -print-predicateinfo < %s 2>&1 | FileCheck %s
+
+declare void @foo()
+declare void @llvm.assume(i1)
+
+define void @bar(i32* %p) {
+entry:
+; CHECK-LABEL: @bar
+ br label %end
+
+unreachable1:
+ %v1 = load i32, i32* %p, align 4
+ %c1 = icmp eq i32 %v1, 0
+ call void @llvm.assume(i1 %c1)
+ br label %unreachable2
+
+unreachable2:
+ %v2 = load i32, i32* %p, align 4
+ %c2 = icmp eq i32 %v2, 0
+ call void @llvm.assume(i1 %c2)
+ br label %end
+
+end:
+ ret void
+}
More information about the llvm-commits
mailing list