[llvm] 9b7b548 - [Attributor] Allow AAs to iterate on their own state
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 11 23:49:23 PST 2023
Author: Johannes Doerfert
Date: 2023-01-11T23:49:10-08:00
New Revision: 9b7b5482fa01413a96fe79c42c3e67ee6730cf6d
URL: https://github.com/llvm/llvm-project/commit/9b7b5482fa01413a96fe79c42c3e67ee6730cf6d
DIFF: https://github.com/llvm/llvm-project/commit/9b7b5482fa01413a96fe79c42c3e67ee6730cf6d.diff
LOG: [Attributor] Allow AAs to iterate on their own state
Future AAs might need to iterate their own state until they reach a
fixpoint. We do not want to forbid that but we want to avoid negative
effects or bugs once this happens. As a precaution, we now rerun an AA
that did not require outside information. If it does not change anymore
we are done, otherwise the AA needs to iterate some more.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 50facdb56a29..416f554edce2 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2411,10 +2411,20 @@ ChangeStatus Attributor::updateAA(AbstractAttribute &AA) {
/* CheckBBLivenessOnly */ true))
CS = AA.update(*this);
- if (!AA.isQueryAA() && DV.empty()) {
- // If the attribute did not query any non-fix information, the state
- // will not change and we can indicate that right away.
- AAState.indicateOptimisticFixpoint();
+ if (!AA.isQueryAA() && DV.empty() && !AA.getState().isAtFixpoint()) {
+ // If the AA did not rely on outside information but changed, we run it
+ // again to see if it found a fixpoint. Most AAs do but we don't require
+ // them to. Hence, it might take the AA multiple iterations to get to a
+ // fixpoint even if it does not rely on outside information, which is fine.
+ ChangeStatus RerunCS = ChangeStatus::UNCHANGED;
+ if (CS == ChangeStatus::CHANGED)
+ RerunCS = AA.update(*this);
+
+ // If the attribute did not change during the run or rerun, and it still did
+ // not query any non-fix information, the state will not change and we can
+ // indicate that right at this point.
+ if (RerunCS == ChangeStatus::UNCHANGED && !AA.isQueryAA() && DV.empty())
+ AAState.indicateOptimisticFixpoint();
}
if (!AAState.isAtFixpoint())
More information about the llvm-commits
mailing list