[NFC][NewPM] Remove some AnalysisManager invalidate methods

These were misleading, they're more of a "clear" than an "invalidate".

We shouldn't be individually clearing analysis results. Either we clear
all analyses when some IR becomes invalid, or we properly go through
invalidation.

There was only one use of this, which can be simulated with
AM.invalidate(F, PA).

Reviewed By: mtrofin

Differential Revision: https://reviews.llvm.org/D100519
This commit is contained in:
Arthur Eubanks 2021-04-14 18:40:07 -07:00
parent 102fd1cb8b
commit 9c776c2fa2
2 changed files with 10 additions and 28 deletions

View File

@ -860,16 +860,6 @@ public:
return true;
}
/// Invalidate a specific analysis pass for an IR unit.
///
/// Note that the analysis result can disregard invalidation, if it determines
/// it is in fact still valid.
template <typename PassT> void invalidate(IRUnitT &IR) {
assert(AnalysisPasses.count(PassT::ID()) &&
"This analysis pass was not registered prior to being invalidated");
invalidateImpl(PassT::ID(), IR);
}
/// Invalidate cached analyses for an IR unit.
///
/// Walk through all of the analyses pertaining to this unit of IR and
@ -904,20 +894,6 @@ private:
return RI == AnalysisResults.end() ? nullptr : &*RI->second->second;
}
/// Invalidate a pass result for a IR unit.
void invalidateImpl(AnalysisKey *ID, IRUnitT &IR) {
typename AnalysisResultMapT::iterator RI =
AnalysisResults.find({ID, &IR});
if (RI == AnalysisResults.end())
return;
if (DebugLogging)
dbgs() << "Invalidating analysis: " << this->lookUpPass(ID).name()
<< " on " << IR.getName() << "\n";
AnalysisResultLists[&IR].erase(RI->second);
AnalysisResults.erase(RI);
}
/// Map type from analysis pass ID to pass concept pointer.
using AnalysisPassMapT =
DenseMap<AnalysisKey *, std::unique_ptr<PassConceptT>>;

View File

@ -1785,8 +1785,11 @@ PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) {
}
Changed |= CFGChanged;
if (CFGChanged && !SkipProfitabilityChecks)
AM.invalidate<BlockFrequencyAnalysis>(F);
if (CFGChanged && !SkipProfitabilityChecks) {
PreservedAnalyses PA = PreservedAnalyses::all();
PA.abandon<BlockFrequencyAnalysis>();
AM.invalidate(F, PA);
}
}
SmallPriorityWorklist<Loop *, 4> Worklist;
@ -1800,8 +1803,11 @@ PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) {
Loop *L = Worklist.pop_back_val();
if (IRCE.run(L, LPMAddNewLoop)) {
Changed = true;
if (!SkipProfitabilityChecks)
AM.invalidate<BlockFrequencyAnalysis>(F);
if (!SkipProfitabilityChecks) {
PreservedAnalyses PA = PreservedAnalyses::all();
PA.abandon<BlockFrequencyAnalysis>();
AM.invalidate(F, PA);
}
}
}