diff options
author | Johannes Doerfert <jdoerfert@anl.gov> | 2019-08-28 16:58:52 +0000 |
---|---|---|
committer | Johannes Doerfert <jdoerfert@anl.gov> | 2019-08-28 16:58:52 +0000 |
commit | f7ca0fe1c86a55a6c7b76809ed339002ec9c08d3 (patch) | |
tree | 8c19172141bfa1f6487506d3d9e91e6b8998fe80 /llvm/lib | |
parent | 8f85685b5cf57eddea11fa444503ade220c724e4 (diff) | |
download | bcm5719-llvm-f7ca0fe1c86a55a6c7b76809ed339002ec9c08d3.tar.gz bcm5719-llvm-f7ca0fe1c86a55a6c7b76809ed339002ec9c08d3.zip |
[Attributor] Regularly clear dependences to remove spurious ones
As dependences between abstract attributes can become stale, e.g., if
one was sufficient to imply another one at some point but it has since
been wakened to the point it is not usable for the formerly implied one.
To weed out spurious dependences, and thereby eliminate unneeded
updates, we introduce an option to determine how often the dependence
cache is cleared and recomputed during the fixpoint iteration.
Note that the initial value was determined such that we see a positive
result on our tests.
Differential Revision: https://reviews.llvm.org/D63315
llvm-svn: 370230
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index d441012000e..be609a2b238 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -123,6 +123,11 @@ static cl::opt<bool> VerifyAttributor( "manifestation of attributes -- may issue false-positive errors"), cl::init(false)); +static cl::opt<unsigned> DepRecInterval( + "attributor-dependence-recompute-interval", cl::Hidden, + cl::desc("Number of iterations until dependences are recomputed."), + cl::init(4)); + /// Logic operators for the change status enum class. /// ///{ @@ -2548,12 +2553,25 @@ ChangeStatus Attributor::run() { SetVector<AbstractAttribute *> Worklist; Worklist.insert(AllAbstractAttributes.begin(), AllAbstractAttributes.end()); + bool RecomputeDependences = false; + do { // Remember the size to determine new attributes. size_t NumAAs = AllAbstractAttributes.size(); LLVM_DEBUG(dbgs() << "\n\n[Attributor] #Iteration: " << IterationCounter << ", Worklist size: " << Worklist.size() << "\n"); + // If dependences (=QueryMap) are recomputed we have to look at all abstract + // attributes again, regardless of what changed in the last iteration. + if (RecomputeDependences) { + LLVM_DEBUG( + dbgs() << "[Attributor] Run all AAs to recompute dependences\n"); + QueryMap.clear(); + ChangedAAs.clear(); + Worklist.insert(AllAbstractAttributes.begin(), + AllAbstractAttributes.end()); + } + // Add all abstract attributes that are potentially dependent on one that // changed to the work list. for (AbstractAttribute *ChangedAA : ChangedAAs) { @@ -2575,6 +2593,10 @@ ChangeStatus Attributor::run() { if (AA->update(*this) == ChangeStatus::CHANGED) ChangedAAs.push_back(AA); + // Check if we recompute the dependences in the next iteration. + RecomputeDependences = (DepRecomputeInterval > 0 && + IterationCounter % DepRecomputeInterval == 0); + // Add attributes to the changed set if they have been created in the last // iteration. ChangedAAs.append(AllAbstractAttributes.begin() + NumAAs, @@ -2589,13 +2611,18 @@ ChangeStatus Attributor::run() { size_t NumFinalAAs = AllAbstractAttributes.size(); + if (VerifyMaxFixpointIterations && IterationCounter != MaxFixpointIterations) { + errs() << "\n[Attributor] Fixpoint iteration done after: " + << IterationCounter << "/" << MaxFixpointIterations + << " iterations\n"; + llvm_unreachable("The fixpoint was not reached with exactly the number of " + "specified iterations!"); + } + LLVM_DEBUG(dbgs() << "\n[Attributor] Fixpoint iteration done after: " << IterationCounter << "/" << MaxFixpointIterations << " iterations\n"); - if (VerifyMaxFixpointIterations && IterationCounter != MaxFixpointIterations) - llvm_unreachable("The fixpoint was not reached with exactly the number of " - "specified iterations!"); bool FinishedAtFixpoint = Worklist.empty(); @@ -2930,7 +2957,7 @@ static bool runAttributorOnModule(Module &M) { // Create an Attributor and initially empty information cache that is filled // while we identify default attribute opportunities. InformationCache InfoCache(M.getDataLayout()); - Attributor A(InfoCache); + Attributor A(InfoCache, DepRecInterval); for (Function &F : M) { // TODO: Not all attributes require an exact definition. Find a way to |