[PATCH] D98444: [FIX] Allow non-constant assume operand bundle operands.

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 11:45:05 PST 2021


jdoerfert created this revision.
jdoerfert added reviewers: zequanwu, fhahn, Tyker, lebedev.ri.
Herald added a subscriber: hiraditya.
Herald added a reviewer: bollu.
jdoerfert requested review of this revision.
Herald added a project: LLVM.

Fixes PR49545


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98444

Files:
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp


Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
===================================================================
--- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -383,6 +383,15 @@
                                        "(nonnull|align|dereferenceable)"));
         ASSERT_TRUE(FindExactlyAttributes(Map, Old, ""));
       }));
+  Tests.push_back(std::make_pair(
+      "call void @llvm.assume(i1 true) [\"align\"(i8* undef, i32 undef)]",
+      [](Instruction *I) {
+        // Don't crash but don't learn from undef.
+        RetainedKnowledgeMap Map;
+        fillMapFromAssume(*cast<IntrinsicInst>(I), Map);
+
+        ASSERT_TRUE(Map.empty());
+      }));
   RunTest(Head, Tail, Tests);
 }
 
Index: llvm/lib/Analysis/AssumeBundleQueries.cpp
===================================================================
--- llvm/lib/Analysis/AssumeBundleQueries.cpp
+++ llvm/lib/Analysis/AssumeBundleQueries.cpp
@@ -88,9 +88,11 @@
       Result[Key][&Assume] = {0, 0};
       continue;
     }
-    unsigned Val = cast<ConstantInt>(
-                       getValueFromBundleOpInfo(Assume, Bundles, ABA_Argument))
-                       ->getZExtValue();
+    auto *CI = dyn_cast<ConstantInt>(
+        getValueFromBundleOpInfo(Assume, Bundles, ABA_Argument));
+    if (!CI)
+      continue;
+    unsigned Val = CI->getZExtValue();
     auto Lookup = Result.find(Key);
     if (Lookup == Result.end() || !Lookup->second.count(&Assume)) {
       Result[Key][&Assume] = {Val, Val};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98444.330042.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/d96f2123/attachment.bin>


More information about the llvm-commits mailing list