Skip to content

Commit 7a68f0f

Browse files
[Attributor] Add a phase flag to Attributor
Add a new flag that indicates which stage in the process we are in. This flag is introduced for handling behavior of `getAAFor` according to the stage. (discussed in D86635) Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D86678
1 parent 5c2db16 commit 7a68f0f

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

llvm/include/llvm/Transforms/IPO/Attributor.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ struct Attributor {
986986
auto &AA = AAType::createForPosition(IRP, *this);
987987

988988
// If we are currenty seeding attributes, enforce seeding rules.
989-
if (SeedingPeriod && !shouldSeedAttribute(AA)) {
989+
if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(AA)) {
990990
AA.getState().indicatePessimisticFixpoint();
991991
return AA;
992992
}
@@ -1022,12 +1022,12 @@ struct Attributor {
10221022

10231023
// Allow seeded attributes to declare dependencies.
10241024
// Remember the seeding state.
1025-
bool OldSeedingPeriod = SeedingPeriod;
1026-
SeedingPeriod = false;
1025+
AttributorPhase OldPhase = Phase;
1026+
Phase = AttributorPhase::UPDATE;
10271027

10281028
updateAA(AA);
10291029

1030-
SeedingPeriod = OldSeedingPeriod;
1030+
Phase = OldPhase;
10311031

10321032
if (TrackDependence && AA.getState().isValidState())
10331033
recordDependence(AA, const_cast<AbstractAttribute &>(*QueryingAA),
@@ -1522,9 +1522,14 @@ struct Attributor {
15221522
/// Invoke instructions with at least a single dead successor block.
15231523
SmallVector<WeakVH, 16> InvokeWithDeadSuccessor;
15241524

1525-
/// Wheather attributes are being `seeded`, always false after ::run function
1526-
/// gets called \see getOrCreateAAFor.
1527-
bool SeedingPeriod = true;
1525+
/// A flag that indicates which stage of the process we are in. Initially, the
1526+
/// phase is SEEDING. Phase is changed in `Attributor::run()`
1527+
enum class AttributorPhase {
1528+
SEEDING,
1529+
UPDATE,
1530+
MANIFEST,
1531+
CLEANUP,
1532+
} Phase = AttributorPhase::SEEDING;
15281533

15291534
/// Functions, blocks, and instructions we delete after manifest is done.
15301535
///

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ ChangeStatus Attributor::cleanupIR() {
13231323
ChangeStatus Attributor::run() {
13241324
TimeTraceScope TimeScope("Attributor::run");
13251325

1326-
SeedingPeriod = false;
1326+
Phase = AttributorPhase::UPDATE;
13271327
runTillFixpoint();
13281328

13291329
// dump graphs on demand
@@ -1336,8 +1336,12 @@ ChangeStatus Attributor::run() {
13361336
if (PrintDependencies)
13371337
DG.print();
13381338

1339+
Phase = AttributorPhase::MANIFEST;
13391340
ChangeStatus ManifestChange = manifestAttributes();
1341+
1342+
Phase = AttributorPhase::CLEANUP;
13401343
ChangeStatus CleanupChange = cleanupIR();
1344+
13411345
return ManifestChange | CleanupChange;
13421346
}
13431347

0 commit comments

Comments
 (0)