diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -969,6 +969,7 @@ /// attribute. Using this after Attributor started running is restricted to /// only the Attributor itself. Initial seeding of AAs can be done via this /// function. + /// NOTE: ForceUpdate is ignored in any stage other than the update stage. template const AAType &getOrCreateAAFor(const IRPosition &IRP, const AbstractAttribute *QueryingAA = nullptr, @@ -976,7 +977,7 @@ DepClassTy DepClass = DepClassTy::OPTIONAL, bool ForceUpdate = false) { if (AAType *AAPtr = lookupAAFor(IRP, QueryingAA, TrackDependence)) { - if (ForceUpdate) + if (ForceUpdate && Phase == AttributorPhase::UPDATE) updateAA(*AAPtr); return *AAPtr; } @@ -1020,6 +1021,13 @@ return AA; } + // If this is queried in the manifest stage, we force the AA to indicate + // pessimistic fixpoint immediately. + if (Phase == AttributorPhase::MANIFEST) { + AA.getState().indicatePessimisticFixpoint(); + return AA; + } + // Allow seeded attributes to declare dependencies. // Remember the seeding state. AttributorPhase OldPhase = Phase; diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -1347,6 +1347,8 @@ ChangeStatus Attributor::updateAA(AbstractAttribute &AA) { TimeTraceScope TimeScope(AA.getName() + "::updateAA"); + assert(Phase == AttributorPhase::UPDATE && + "We can update AA only in the update stage!"); // Use a new dependence vector for this update. DependenceVector DV;