[llvm] a8610d7 - [Attributor] Move recursion reasoning into `AA::isPotentiallyReachable`
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 5 18:49:28 PDT 2022
Author: Johannes Doerfert
Date: 2022-04-05T20:49:03-05:00
New Revision: a8610d752306b48f914eb21108f2d1cb1fd6b710
URL: https://github.com/llvm/llvm-project/commit/a8610d752306b48f914eb21108f2d1cb1fd6b710
DIFF: https://github.com/llvm/llvm-project/commit/a8610d752306b48f914eb21108f2d1cb1fd6b710.diff
LOG: [Attributor] Move recursion reasoning into `AA::isPotentiallyReachable`
With D106397 we ensured that `AAReachability` will not answer queries for
potentially recursive functions. This was necessary as we did not treat
recursion explicitly otherwise. Now that we have
`AA::isPotentiallyReachable` we can make `AAReachability` a purely
intra-procedural AA which does not care about recursion.
`AA::isPotentiallyReachable`, however, does already deal with "going
back" the call graph and can now do so for potentially recursive
functions.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index d2c965308cb6c..489914b27ccae 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -519,6 +519,8 @@ isPotentiallyReachable(Attributor &A, const Instruction &FromI,
SmallVector<const Instruction *> Worklist;
Worklist.push_back(&FromI);
+ const auto &NoRecurseAA = A.getAAFor<AANoRecurse>(
+ QueryingAA, IRPosition::function(ToFn), DepClassTy::OPTIONAL);
while (!Worklist.empty()) {
const Instruction *CurFromI = Worklist.pop_back_val();
if (!Visited.insert(CurFromI).second)
@@ -538,7 +540,8 @@ isPotentiallyReachable(Attributor &A, const Instruction &FromI,
<< *ToI << " [Intra]\n");
if (Result)
return true;
- continue;
+ if (NoRecurseAA.isAssumedNoRecurse())
+ continue;
}
// TODO: If we can go arbitrarily backwards we will eventually reach an
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index fc9794632e19d..b8c48648d24c8 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -3071,10 +3071,6 @@ struct AAReachabilityImpl : AAReachability {
/// See AbstractAttribute::updateImpl(...).
ChangeStatus updateImpl(Attributor &A) override {
- const auto &NoRecurseAA = A.getAAFor<AANoRecurse>(
- *this, IRPosition::function(*getAnchorScope()), DepClassTy::REQUIRED);
- if (!NoRecurseAA.isAssumedNoRecurse())
- return indicatePessimisticFixpoint();
return ChangeStatus::UNCHANGED;
}
};
@@ -3306,12 +3302,6 @@ struct AANoAliasCallSiteArgument final : AANoAliasImpl {
return true;
if (ScopeFn) {
- const auto &ReachabilityAA = A.getAAFor<AAReachability>(
- *this, IRPosition::function(*ScopeFn), DepClassTy::OPTIONAL);
-
- if (!ReachabilityAA.isAssumedReachable(A, *UserI, *getCtxI()))
- return true;
-
if (auto *CB = dyn_cast<CallBase>(UserI)) {
if (CB->isArgOperand(&U)) {
@@ -3325,6 +3315,9 @@ struct AANoAliasCallSiteArgument final : AANoAliasImpl {
return true;
}
}
+
+ if (!AA::isPotentiallyReachable(A, *UserI, *getCtxI(), *this))
+ return true;
}
// For cases which can potentially have more users
More information about the llvm-commits
mailing list