From: Johannes Doerfert Date: Thu, 12 Jan 2023 01:47:14 +0000 (-0800) Subject: [Attributor] Allow AAs to iterate on their own state X-Git-Tag: upstream/17.0.6~21258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b7b5482fa01413a96fe79c42c3e67ee6730cf6d;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 50facdb..416f554 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())