Skip to content

Commit 2dad729

Browse files
committed
[Attributor][NFC] Eagerly mark attributes as fixed.
If an attribute did not query any optimistic (=non-fixed) information to justify its state, we know the attribute state will not change anymore. Thus, we can indicate an optimistic fixpoint.
1 parent 12173e6 commit 2dad729

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ struct Attributor {
959959
/// The information cache that holds pre-processed (LLVM-IR) information.
960960
InformationCache &InfoCache;
961961

962+
/// Set if the attribute currently updated did query a non-fix attribute.
963+
bool QueriedNonFixAA;
964+
962965
/// Number of iterations until the dependences between abstract attributes are
963966
/// recomputed.
964967
const unsigned DepRecomputeInterval;

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,9 +4496,16 @@ ChangeStatus Attributor::run(Module &M) {
44964496
// Update all abstract attribute in the work list and record the ones that
44974497
// changed.
44984498
for (AbstractAttribute *AA : Worklist)
4499-
if (!isAssumedDead(*AA, nullptr))
4500-
if (AA->update(*this) == ChangeStatus::CHANGED)
4499+
if (!AA->getState().isAtFixpoint() && !isAssumedDead(*AA, nullptr)) {
4500+
QueriedNonFixAA = false;
4501+
if (AA->update(*this) == ChangeStatus::CHANGED) {
45014502
ChangedAAs.push_back(AA);
4503+
} else if (!QueriedNonFixAA) {
4504+
// If the attribute did not query any non-fix information, the state
4505+
// will not change and we can indicate that right away.
4506+
AA->getState().indicateOptimisticFixpoint();
4507+
}
4508+
}
45024509

45034510
// Check if we recompute the dependences in the next iteration.
45044511
RecomputeDependences = (DepRecomputeInterval > 0 &&
@@ -4713,8 +4720,11 @@ void Attributor::initializeInformationCache(Function &F) {
47134720

47144721
void Attributor::recordDependence(const AbstractAttribute &FromAA,
47154722
const AbstractAttribute &ToAA) {
4716-
if (!FromAA.getState().isAtFixpoint())
4717-
QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
4723+
if (FromAA.getState().isAtFixpoint())
4724+
return;
4725+
4726+
QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
4727+
QueriedNonFixAA = true;
47184728
}
47194729

47204730
void Attributor::identifyDefaultAbstractAttributes(Function &F) {

0 commit comments

Comments
 (0)