[llvm] 0cd964f - [Attributor][FIX] checkForAllInstructions, correctly handle declarations
Kuter Dinel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 23 16:23:17 PDT 2021
Author: Kuter Dinel
Date: 2021-07-24T02:21:29+03:00
New Revision: 0cd964ff254888d563659f4f8f39c934732aa487
URL: https://github.com/llvm/llvm-project/commit/0cd964ff254888d563659f4f8f39c934732aa487
DIFF: https://github.com/llvm/llvm-project/commit/0cd964ff254888d563659f4f8f39c934732aa487.diff
LOG: [Attributor][FIX] checkForAllInstructions, correctly handle declarations
checkForAllInstructions was not handling declarations correctly.
It should have been returning false when it gets called on a declaration
The patch also fixes a test case for AAFunctionReachability for it to be able
to pass after the changes to the checkForAllinstructions.
Differential Revision: https://reviews.llvm.org/D106625
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/unittests/Transforms/IPO/AttributorTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index fcee3afe8d97c..1e4d990e0df19 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1146,6 +1146,9 @@ bool Attributor::checkForAllInstructions(function_ref<bool(Instruction &)> Pred,
if (!AssociatedFunction)
return false;
+ if (AssociatedFunction->isDeclaration())
+ return false;
+
// TODO: use the function scope once we have call site AAReturnedValues.
const IRPosition &QueryIRP = IRPosition::function(*AssociatedFunction);
const auto *LivenessAA =
diff --git a/llvm/unittests/Transforms/IPO/AttributorTest.cpp b/llvm/unittests/Transforms/IPO/AttributorTest.cpp
index 8bbea568b391f..51de06c6d5e17 100644
--- a/llvm/unittests/Transforms/IPO/AttributorTest.cpp
+++ b/llvm/unittests/Transforms/IPO/AttributorTest.cpp
@@ -75,8 +75,16 @@ TEST_F(AttributorTestBase, TestCast) {
TEST_F(AttributorTestBase, AAReachabilityTest) {
const char *ModuleString = R"(
- declare void @func4()
- declare void @func3()
+ @x = global i32 0
+ define void @func4() {
+ store i32 0, i32* @x
+ ret void
+ }
+
+ define void @func3() {
+ store i32 0, i32* @x
+ ret void
+ }
define void @func2() {
entry:
More information about the llvm-commits
mailing list