diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h --- a/llvm/include/llvm/Analysis/CallGraph.h +++ b/llvm/include/llvm/Analysis/CallGraph.h @@ -112,6 +112,9 @@ /// Returns the module the call graph corresponds to. Module &getModule() const { return M; } + bool invalidate(Module &, const PreservedAnalyses &PA, + ModuleAnalysisManager::Invalidator &); + inline iterator begin() { return FunctionMap.begin(); } inline iterator end() { return FunctionMap.end(); } inline const_iterator begin() const { return FunctionMap.begin(); } diff --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp --- a/llvm/lib/Analysis/CallGraph.cpp +++ b/llvm/lib/Analysis/CallGraph.cpp @@ -57,6 +57,15 @@ #endif } +bool CallGraph::invalidate(Module &, const PreservedAnalyses &PA, + ModuleAnalysisManager::Invalidator &) { + // Check whether the analysis, all analyses on functions, or the function's + // CFG have been preserved. + auto PAC = PA.getChecker(); + return !(PAC.preserved() || PAC.preservedSet>() || + PAC.preservedSet()); +} + void CallGraph::addToCallGraph(Function *F) { CallGraphNode *Node = getOrInsertFunction(F);