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>
44 std::unique_ptr<llzk::CallGraph> cg;
57 using CalleeMapTy = mlir::DenseMap<function::FuncDefOp, mlir::DenseSet<function::FuncDefOp>>;
59 mutable CalleeMapTy reachabilityMap;
61 std::reference_wrapper<llzk::CallGraph> callGraph;
66 bool isInvalidated(
const mlir::AnalysisManager::PreservedAnalyses &pa) {
77 auto it = reachabilityMap.find(A);
78 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)
bool isInvalidated(const mlir::AnalysisManager::PreservedAnalyses &pa)
const llzk::CallGraph & getCallGraph() const
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 ...