summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-09-07 07:23:39 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-09-07 07:23:39 +0000
commit9e6845d8e12e4dba18e62a04a7980860eb3f46d2 (patch)
tree284d90a614a6d8f428f39e07f6b7c484eb63b2f2
parent3ab0ee4d9b0fa7c5953a811b8d4703761b041afa (diff)
downloadbcm5719-llvm-9e6845d8e12e4dba18e62a04a7980860eb3f46d2.tar.gz
bcm5719-llvm-9e6845d8e12e4dba18e62a04a7980860eb3f46d2.zip
[IndVars] Set Changed when we delete dead instructions. PR38855
IndVars does not set `Changed` flag when it eliminates dead instructions. As result, it may make IR modifications and report that it has done nothing. It leads to inconsistent preserved analyzes results. Differential Revision: https://reviews.llvm.org/D51770 Reviewed By: skatkov llvm-svn: 341633
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp2
-rw-r--r--llvm/test/Transforms/IndVarSimplify/pr38855.ll24
2 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 06836360610..80b7a42652a 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2491,7 +2491,7 @@ bool IndVarSimplify::run(Loop *L) {
while (!DeadInsts.empty())
if (Instruction *Inst =
dyn_cast_or_null<Instruction>(DeadInsts.pop_back_val()))
- RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
+ Changed |= RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
// The Rewriter may not be used from this point on.
diff --git a/llvm/test/Transforms/IndVarSimplify/pr38855.ll b/llvm/test/Transforms/IndVarSimplify/pr38855.ll
new file mode 100644
index 00000000000..b2d84e7abaf
--- /dev/null
+++ b/llvm/test/Transforms/IndVarSimplify/pr38855.ll
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -inline -functionattrs -indvars < %s | FileCheck %s
+
+; Check that the invalidation happens correctly and the test does not crash.
+define void @f2() {
+; CHECK-LABEL: @f2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_COND:%.*]]
+; CHECK: for.cond:
+; CHECK-NEXT: br label [[FOR_COND]]
+;
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.cond, %entry
+ %a.0 = phi i32 [ 1, %entry ], [ 0, %for.cond ]
+ call void @f1(i32 %a.0)
+ br label %for.cond
+}
+
+define internal void @f1(i32 %p1) noinline {
+entry:
+ ret void
+}
OpenPOWER on IntegriCloud