Index: llvm/include/llvm/Transforms/IPO/Attributor.h =================================================================== --- llvm/include/llvm/Transforms/IPO/Attributor.h +++ llvm/include/llvm/Transforms/IPO/Attributor.h @@ -986,7 +986,7 @@ auto &AA = AAType::createForPosition(IRP, *this); // If we are currenty seeding attributes, enforce seeding rules. - if (SeedingPeriod && !shouldSeedAttribute(AA)) { + if (Phase == SEEDING && !shouldSeedAttribute(AA)) { AA.getState().indicatePessimisticFixpoint(); return AA; } @@ -1022,12 +1022,12 @@ // Allow seeded attributes to declare dependencies. // Remember the seeding state. - bool OldSeedingPeriod = SeedingPeriod; - SeedingPeriod = false; + AttributorPhase OldPhase = Phase; + Phase = UPDATE; updateAA(AA); - SeedingPeriod = OldSeedingPeriod; + Phase = OldPhase; if (TrackDependence && AA.getState().isValidState()) recordDependence(AA, const_cast(*QueryingAA), @@ -1522,9 +1522,15 @@ /// Invoke instructions with at least a single dead successor block. SmallVector InvokeWithDeadSuccessor; - /// Wheather attributes are being `seeded`, always false after ::run function - /// gets called \see getOrCreateAAFor. - bool SeedingPeriod = true; + /// A flag that indicates which stage of the process we are in. Initially, the + /// phase is SEEDING. UPDATE, MANIFEST and CLEANUP correspond to + /// ::runTillFixpoint, ::manifestAttributes and ::cleanupIR, respectively. + enum AttributorPhase { + SEEDING, + UPDATE, + MANIFEST, + CLEANUP, + } Phase = SEEDING; /// Functions, blocks, and instructions we delete after manifest is done. /// Index: llvm/lib/Transforms/IPO/Attributor.cpp =================================================================== --- llvm/lib/Transforms/IPO/Attributor.cpp +++ llvm/lib/Transforms/IPO/Attributor.cpp @@ -949,6 +949,7 @@ } void Attributor::runTillFixpoint() { + Phase = UPDATE; TimeTraceScope TimeScope("Attributor::runTillFixpoint"); LLVM_DEBUG(dbgs() << "[Attributor] Identified and initialized " << DG.SyntheticRoot.Deps.size() @@ -1086,6 +1087,7 @@ } ChangeStatus Attributor::manifestAttributes() { + Phase = MANIFEST; TimeTraceScope TimeScope("Attributor::manifestAttributes"); size_t NumFinalAAs = DG.SyntheticRoot.Deps.size(); @@ -1149,6 +1151,7 @@ } ChangeStatus Attributor::cleanupIR() { + Phase = CLEANUP; TimeTraceScope TimeScope("Attributor::cleanupIR"); // Delete stuff at the end to avoid invalid references and a nice order. LLVM_DEBUG(dbgs() << "\n[Attributor] Delete at least " @@ -1320,7 +1323,6 @@ ChangeStatus Attributor::run() { TimeTraceScope TimeScope("Attributor::run"); - SeedingPeriod = false; runTillFixpoint(); // dump graphs on demand