15#include <mlir/Pass/AnalysisManager.h>
17#include <llvm/ADT/DenseMap.h>
18#include <llvm/ADT/DenseSet.h>
19#include <llvm/ADT/SCCIterator.h>
20#include <llvm/ADT/STLExtras.h>
36 std::unique_ptr<llzk::CallGraph> cg;
49 using CalleeMapTy = mlir::DenseMap<function::FuncDefOp, mlir::DenseSet<function::FuncDefOp>>;
51 mutable CalleeMapTy reachabilityMap;
53 std::reference_wrapper<llzk::CallGraph> callGraph;
58 static bool isInvalidated(
const mlir::AnalysisManager::PreservedAnalyses &pa) {
69 auto it = reachabilityMap.find(A);
70 return it != reachabilityMap.
end() && it->second.find(B) != it->second.end();
An analysis wrapper to compute the CallGraph for a Module.
llzk::CallGraph & getCallGraph()
const llzk::CallGraph & getCallGraph() const
CallGraphAnalysis(mlir::Operation *op)
const llzk::CallGraph & getCallGraph() const
static bool isInvalidated(const mlir::AnalysisManager::PreservedAnalyses &pa)
CallGraphReachabilityAnalysis(mlir::Operation *, mlir::AnalysisManager &am)
NOTE: the need for the mlir::Operation argument is a requirement of the mlir::getAnalysis method,...
bool isReachable(function::FuncDefOp &A, function::FuncDefOp &B) const
Returns whether B is reachable from A.
This is a port of mlir::CallGraph that has been adapted to use the custom symbol lookup helpers (see ...