Skip to content

Commit 84d68ca

Browse files
committed
add a new method
1 parent 372382d commit 84d68ca

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/include/llvm/IR/PassManager.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,22 @@ template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager {
491491
/// invalidate them, unless they are preserved by the PreservedAnalyses set.
492492
void invalidate(IRUnitT &IR, const PreservedAnalyses &PA);
493493

494+
/// Directly clear a cached analysis for an IR unit.
495+
///
496+
/// Using invalidate() over this is preferred unless you are really
497+
/// sure you want to *only* clear this analysis without asking if it is
498+
/// invalid.
499+
template <typename AnalysisT> void clearAnalysis(IRUnitT &IR) {
500+
AnalysisResultListT &ResultsList = AnalysisResultLists[&IR];
501+
AnalysisKey *ID = AnalysisT::ID();
502+
503+
auto I =
504+
llvm::find_if(ResultsList, [&ID](auto &E) { return E.first == ID; });
505+
assert(I != ResultsList.end() && "Analysis must be available");
506+
ResultsList.erase(I);
507+
AnalysisResults.erase({ID, &IR});
508+
}
509+
494510
private:
495511
/// Look up a registered analysis pass.
496512
PassConceptT &lookUpPass(AnalysisKey *ID) {

llvm/lib/CodeGen/MachineFunctionAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ MachineFunctionAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
4848

4949
PreservedAnalyses FreeAllAnalysesPass::run(Function &F,
5050
FunctionAnalysisManager &FAM) {
51-
FAM.clear(F, F.getName());
51+
FAM.clearAnalysis<MachineFunctionAnalysis>(F);
5252
return PreservedAnalyses::all();
5353
}

0 commit comments

Comments
 (0)