[PATCH] D38765: Don't replace constants with constants in GVN
Alex Crichton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 21:10:43 PDT 2017
alexcrichton updated this revision to Diff 118535.
https://reviews.llvm.org/D38765
Files:
lib/Transforms/Scalar/GVN.cpp
test/Transforms/GVN/no-crash-on-undef-assume.ll
Index: test/Transforms/GVN/no-crash-on-undef-assume.ll
===================================================================
--- /dev/null
+++ test/Transforms/GVN/no-crash-on-undef-assume.ll
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -gvn -S | FileCheck %s
+
+define i1 @foo() {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: call void @llvm.assume(i1 undef)
+; CHECK-NEXT: ret i1 undef
+;
+ call void @llvm.assume(i1 undef)
+ ret i1 undef
+}
+
+declare void @llvm.assume(i1)
Index: lib/Transforms/Scalar/GVN.cpp
===================================================================
--- lib/Transforms/Scalar/GVN.cpp
+++ lib/Transforms/Scalar/GVN.cpp
@@ -1362,6 +1362,11 @@
}
markInstructionForDeletion(IntrinsicI);
return false;
+ } else if (isa<Constant>(V)) {
+ // if it's not false, and constant, it must evaluate to true. This means our
+ // assume is assume(true), and thus, pointless, and we don't want to do
+ // anything more here
+ return false;
}
Constant *True = ConstantInt::getTrue(V->getContext());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38765.118535.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/637cb1cc/attachment.bin>
More information about the llvm-commits
mailing list