Skip to content

Commit 06d5663

Browse files
committed
add a new method
1 parent f6ad314 commit 06d5663

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
@@ -489,6 +489,22 @@ template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager {
489489
/// invalidate them, unless they are preserved by the PreservedAnalyses set.
490490
void invalidate(IRUnitT &IR, const PreservedAnalyses &PA);
491491

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