Index: llvm/include/llvm/Transforms/IPO/Attributor.h =================================================================== --- llvm/include/llvm/Transforms/IPO/Attributor.h +++ llvm/include/llvm/Transforms/IPO/Attributor.h @@ -965,6 +965,18 @@ /* ForceUpdate */ true); } + /// Return abstract attribute of type \p AAType at position \p IRP. If the AA + /// has not been initialized, this initializes it and forces it to indicate + /// a pessimistic fixpoint. We should use this when we want to query abstract + /// attributes in AbstractAttribute::manifest. + template + const AAType &getAADuringManifestFor(const IRPosition &IRP) { + return getOrCreateAAFor(IRP, nullptr, /* TrackDependence */ false, + DepClassTy::OPTIONAL, + /* ForceUpdate */ false, + /* DuringManifest */ true); + } + /// The version of getAAFor that allows to omit a querying abstract /// attribute. Using this after Attributor started running is restricted to /// only the Attributor itself. Initial seeding of AAs can be done via this @@ -974,10 +986,13 @@ const AbstractAttribute *QueryingAA = nullptr, bool TrackDependence = false, DepClassTy DepClass = DepClassTy::OPTIONAL, - bool ForceUpdate = false) { + bool ForceUpdate = false, + bool DuringManifest = false) { if (AAType *AAPtr = lookupAAFor(IRP, QueryingAA, TrackDependence)) { - if (ForceUpdate) + if (ForceUpdate) { + assert(!DuringManifest && "We cannot update AA during manifestation!"); updateAA(*AAPtr); + } return *AAPtr; } @@ -1020,6 +1035,13 @@ return AA; } + // If this is queried during manifestation, we immediately force it to + // indicate a pessimistic fixpoint. + if (DuringManifest) { + AA.getState().indicatePessimisticFixpoint(); + return AA; + } + // Allow seeded attributes to declare dependencies. // Remember the seeding state. bool OldSeedingPeriod = SeedingPeriod; Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp =================================================================== --- llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -3065,9 +3065,8 @@ auto *CB = dyn_cast(DeadEndI); if (!CB) continue; - const auto &NoReturnAA = A.getAndUpdateAAFor( - *this, IRPosition::callsite_function(*CB), /* TrackDependence */ true, - DepClassTy::OPTIONAL); + const auto &NoReturnAA = A.getAADuringManifestFor( + IRPosition::callsite_function(*CB)); bool MayReturn = !NoReturnAA.isAssumedNoReturn(); if (MayReturn && (!Invoke2CallAllowed || !isa(CB))) continue; @@ -5540,7 +5539,8 @@ Argument *Arg = getAssociatedArgument(); // Query AAAlign attribute for alignment of associated argument to // determine the best alignment of loads. - const auto &AlignAA = A.getAAFor(*this, IRPosition::value(*Arg)); + const auto &AlignAA = + A.getAADuringManifestFor(IRPosition::value(*Arg)); // Callback to repair the associated function. A new alloca is placed at the // beginning and initialized with the values passed through arguments. The