[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 21:31:30 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd22fbccfe251: [FIX] Allow non-constant assume operand bundle operands. (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98444/new/

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.330139.patch
Type: text/x-patch
Size: 1554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210312/ec4a43d2/attachment.bin>


More information about the llvm-commits mailing list