[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:02:29 PDT 2017


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

Ok thanks for the help! I've updated with some `CHECK` directives now. Mind helping me land the patch as well?


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,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.118534.patch
Type: text/x-patch
Size: 923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171011/f67d94ad/attachment.bin>


More information about the llvm-commits mailing list