LLVM 18.0.0git
|
Wrapper to unify "old style" CallGraph and "new style" LazyCallGraph. More...
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
Public Member Functions | |
CallGraphUpdater ()=default | |
} | |
~CallGraphUpdater () | |
void | initialize (CallGraph &CG, CallGraphSCC &SCC) |
Initializers for usage outside of a CGSCC pass, inside a CGSCC pass in the old and new pass manager (PM). | |
void | initialize (LazyCallGraph &LCG, LazyCallGraph::SCC &SCC, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR) |
bool | finalize () |
} | |
void | removeFunction (Function &Fn) |
Remove Fn from the call graph. | |
void | reanalyzeFunction (Function &Fn) |
After an CGSCC pass changes a function in ways that affect the call graph, this method can be called to update it. | |
void | registerOutlinedFunction (Function &OriginalFn, Function &NewFn) |
If a new function was created by outlining, this method can be called to update the call graph for the new function. | |
void | replaceFunctionWith (Function &OldFn, Function &NewFn) |
Replace OldFn in the call graph (and SCC) with NewFn . | |
void | removeCallSite (CallBase &CS) |
Remove the call site CS from the call graph. | |
bool | replaceCallSite (CallBase &OldCS, CallBase &NewCS) |
Replace OldCS with the new call site NewCS . | |
Wrapper to unify "old style" CallGraph and "new style" LazyCallGraph.
This simplifies the interface and the call sites, e.g., new and old pass manager passes can share the same code.
Definition at line 29 of file CallGraphUpdater.h.
|
default |
}
|
inline |
Definition at line 58 of file CallGraphUpdater.h.
References finalize().
bool CallGraphUpdater::finalize | ( | ) |
}
Finalizer that will trigger actions like function removal from the CG.
Definition at line 24 of file CallGraphUpdater.cpp.
References assert(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::clear(), FAM, llvm::filterDeadComdatFunctions(), llvm::LazyCallGraph::get(), llvm::PoisonValue::get(), llvm::CallGraph::getExternalCallingNode(), llvm::CallGraphNode::getNumReferences(), llvm::CallGraph::getOrInsertFunction(), llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult(), llvm::CGSCCUpdateResult::InvalidatedRefSCCs, llvm::CGSCCUpdateResult::InvalidatedSCCs, llvm::LazyCallGraph::lookupSCC(), N, llvm::CallGraphNode::removeAllCalledFunctions(), llvm::CallGraphNode::removeAnyCallEdgeTo(), llvm::Constant::removeDeadConstantUsers(), llvm::LazyCallGraph::removeDeadFunction(), and llvm::CallGraph::removeFunctionFromModule().
Referenced by ~CallGraphUpdater().
|
inline |
Initializers for usage outside of a CGSCC pass, inside a CGSCC pass in the old and new pass manager (PM).
{
Definition at line 63 of file CallGraphUpdater.h.
Referenced by llvm::AttributorCGSCCPass::run(), llvm::AttributorLightCGSCCPass::run(), and llvm::OpenMPOptCGSCCPass::run().
|
inline |
Definition at line 67 of file CallGraphUpdater.h.
References FAM, and llvm::AnalysisManager< IRUnitT, ExtraArgTs >::getResult().
void CallGraphUpdater::reanalyzeFunction | ( | Function & | Fn | ) |
After an CGSCC pass changes a function in ways that affect the call graph, this method can be called to update it.
Definition at line 89 of file CallGraphUpdater.cpp.
References llvm::CallingConv::C, llvm::LazyCallGraph::get(), llvm::CallGraph::getOrInsertFunction(), llvm::LazyCallGraph::lookupSCC(), N, llvm::CallGraph::populateCallGraphNode(), llvm::CallGraphNode::removeAllCalledFunctions(), and llvm::updateCGAndAnalysisManagerForCGSCCPass().
Referenced by runAttributorOnFunctions().
If a new function was created by outlining, this method can be called to update the call graph for the new function.
Note that the old one still needs to be re-analyzed or manually updated.
Definition at line 101 of file CallGraphUpdater.cpp.
References llvm::LazyCallGraph::addSplitFunction(), and llvm::CallGraph::addToCallGraph().
void CallGraphUpdater::removeCallSite | ( | CallBase & | CS | ) |
Remove the call site CS
from the call graph.
Definition at line 164 of file CallGraphUpdater.cpp.
References llvm::CallBase::getCaller(), and llvm::CallGraphNode::removeCallEdgeFor().
Referenced by llvm::Attributor::removeCallSite().
void CallGraphUpdater::removeFunction | ( | Function & | Fn | ) |
Remove Fn
from the call graph.
Definition at line 109 of file CallGraphUpdater.cpp.
References llvm::AnalysisManager< IRUnitT, ExtraArgTs >::clear(), llvm::Function::deleteBody(), llvm::CallGraphSCC::DeleteNode(), llvm::GlobalValue::ExternalLinkage, llvm::Value::getName(), llvm::GlobalObject::hasComdat(), llvm::CallGraphNode::removeAllCalledFunctions(), and llvm::GlobalValue::setLinkage().
Referenced by replaceFunctionWith().
Replace OldCS
with the new call site NewCS
.
OldCB
needs to be re-analyzed. Definition at line 147 of file CallGraphUpdater.cpp.
References llvm::CallBase::getCalledFunction(), llvm::CallBase::getCaller(), llvm::CallGraph::getOrInsertFunction(), llvm::none_of(), and llvm::CallGraphNode::replaceCallEdge().
Replace OldFn
in the call graph (and SCC) with NewFn
.
The uses outside the call graph and the function OldFn
are not modified. Note that OldFn
is also removed from the call graph (
Definition at line 127 of file CallGraphUpdater.cpp.
References llvm::LazyCallGraph::get(), llvm::CallGraph::getOrInsertFunction(), llvm::LazyCallGraph::SCC::getOuterRefSCC(), llvm::Constant::removeDeadConstantUsers(), removeFunction(), llvm::CallGraph::ReplaceExternalCallEdge(), llvm::CallGraphSCC::ReplaceNode(), llvm::LazyCallGraph::RefSCC::replaceNodeFunction(), and llvm::CallGraphNode::stealCalledFunctionsFrom().
Referenced by runAttributorOnFunctions().