[llvm] 2dad729 - [Attributor][NFC] Eagerly mark attributes as fixed.
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 18:48:28 PDT 2019
Author: Johannes Doerfert
Date: 2019-10-30T20:47:47-05:00
New Revision: 2dad729f0c7b8665d362baecd8ff52449b26051d
URL: https://github.com/llvm/llvm-project/commit/2dad729f0c7b8665d362baecd8ff52449b26051d
DIFF: https://github.com/llvm/llvm-project/commit/2dad729f0c7b8665d362baecd8ff52449b26051d.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 43c1811059a3..17cc11491fda 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -959,6 +959,9 @@ struct Attributor {
/// The information cache that holds pre-processed (LLVM-IR) information.
InformationCache &InfoCache;
+ /// Set if the attribute currently updated did query a non-fix attribute.
+ bool QueriedNonFixAA;
+
/// Number of iterations until the dependences between abstract attributes are
/// recomputed.
const unsigned DepRecomputeInterval;
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index a18be0c78497..567ec7829500 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -4496,9 +4496,16 @@ ChangeStatus Attributor::run(Module &M) {
// Update all abstract attribute in the work list and record the ones that
// changed.
for (AbstractAttribute *AA : Worklist)
- if (!isAssumedDead(*AA, nullptr))
- if (AA->update(*this) == ChangeStatus::CHANGED)
+ if (!AA->getState().isAtFixpoint() && !isAssumedDead(*AA, nullptr)) {
+ QueriedNonFixAA = false;
+ if (AA->update(*this) == ChangeStatus::CHANGED) {
ChangedAAs.push_back(AA);
+ } else if (!QueriedNonFixAA) {
+ // If the attribute did not query any non-fix information, the state
+ // will not change and we can indicate that right away.
+ AA->getState().indicateOptimisticFixpoint();
+ }
+ }
// Check if we recompute the dependences in the next iteration.
RecomputeDependences = (DepRecomputeInterval > 0 &&
@@ -4713,8 +4720,11 @@ void Attributor::initializeInformationCache(Function &F) {
void Attributor::recordDependence(const AbstractAttribute &FromAA,
const AbstractAttribute &ToAA) {
- if (!FromAA.getState().isAtFixpoint())
- QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
+ if (FromAA.getState().isAtFixpoint())
+ return;
+
+ QueryMap[&FromAA].insert(const_cast<AbstractAttribute *>(&ToAA));
+ QueriedNonFixAA = true;
}
void Attributor::identifyDefaultAbstractAttributes(Function &F) {
More information about the llvm-commits
mailing list