[llvm] d22fbcc - [FIX] Allow non-constant assume operand bundle operands.
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 11 21:31:17 PST 2021
Author: Johannes Doerfert
Date: 2021-03-11T23:31:09-06:00
New Revision: d22fbccfe251f5839d9df4c3bbbcc745163a28e9
URL: https://github.com/llvm/llvm-project/commit/d22fbccfe251f5839d9df4c3bbbcc745163a28e9
DIFF: https://github.com/llvm/llvm-project/commit/d22fbccfe251f5839d9df4c3bbbcc745163a28e9.diff
LOG: [FIX] Allow non-constant assume operand bundle operands.
Fixes PR49545
Reviewed By: zequanwu, fhahn, lebedev.ri
Differential Revision: https://reviews.llvm.org/D98444
Added:
Modified:
llvm/lib/Analysis/AssumeBundleQueries.cpp
llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp
index 273b38a9567e..9cb5b10570b3 100644
--- a/llvm/lib/Analysis/AssumeBundleQueries.cpp
+++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp
@@ -88,9 +88,11 @@ void llvm::fillMapFromAssume(CallInst &AssumeCI, RetainedKnowledgeMap &Result) {
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};
diff --git a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
index 946368e1cb94..a66e365f237e 100644
--- a/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
+++ b/llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp
@@ -383,6 +383,15 @@ TEST(AssumeQueryAPI, fillMapFromAssume) {
"(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);
}
More information about the llvm-commits
mailing list