diff --git a/lib/Transforms/IPO/Attributor.cpp b/lib/Transforms/IPO/Attributor.cpp index fcee3afe8d9..1e4d990e0df 100644 --- a/lib/Transforms/IPO/Attributor.cpp +++ b/lib/Transforms/IPO/Attributor.cpp @@ -1146,6 +1146,9 @@ bool Attributor::checkForAllInstructions(function_ref 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/unittests/Transforms/IPO/AttributorTest.cpp b/unittests/Transforms/IPO/AttributorTest.cpp index 8bbea568b39..51de06c6d5e 100644 --- a/unittests/Transforms/IPO/AttributorTest.cpp +++ b/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: