[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 20:39:32 PDT 2017


alexcrichton updated this revision to Diff 118531.
alexcrichton added a comment.

Sure thing, updated!

Unfortunately the original Rust issue is sort of hard to reproduce. It only came up during ThinLTO passes which I didn't find easy to run from the LLVM CLI tools, but I can always provide the original IR (it's quite large) if desired!


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,8 @@
+; RUN: opt < %s -gvn -S
+
+define i1 @foo() {
+    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,8 @@
     }
     markInstructionForDeletion(IntrinsicI);
     return false;
+  } else if (isa<Constant>(V)) {
+    return false;
   }
 
   Constant *True = ConstantInt::getTrue(V->getContext());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38765.118531.patch
Type: text/x-patch
Size: 729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/f8203abe/attachment.bin>


More information about the llvm-commits mailing list