LLVM 19.0.0git
Public Member Functions | List of all members
llvm::CallGraphUpdater Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CallGraphUpdater()

llvm::CallGraphUpdater::CallGraphUpdater ( )
default

}

◆ ~CallGraphUpdater()

llvm::CallGraphUpdater::~CallGraphUpdater ( )
inline

Definition at line 58 of file CallGraphUpdater.h.

References finalize().

Member Function Documentation

◆ finalize()

bool CallGraphUpdater::finalize ( )

◆ initialize() [1/2]

void llvm::CallGraphUpdater::initialize ( CallGraph CG,
CallGraphSCC SCC 
)
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().

◆ initialize() [2/2]

void llvm::CallGraphUpdater::initialize ( LazyCallGraph LCG,
LazyCallGraph::SCC SCC,
CGSCCAnalysisManager AM,
CGSCCUpdateResult UR 
)
inline

◆ reanalyzeFunction()

void CallGraphUpdater::reanalyzeFunction ( Function Fn)

◆ registerOutlinedFunction()

void CallGraphUpdater::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.

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().

◆ removeCallSite()

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().

◆ removeFunction()

void CallGraphUpdater::removeFunction ( Function Fn)

◆ replaceCallSite()

bool CallGraphUpdater::replaceCallSite ( CallBase OldCS,
CallBase NewCS 
)

Replace OldCS with the new call site NewCS.

Returns
True if the replacement was successful, otherwise False. In the latter case the parent function of 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().

◆ replaceFunctionWith()

void CallGraphUpdater::replaceFunctionWith ( Function OldFn,
Function NewFn 
)

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 (

See also
removeFunction).

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().


The documentation for this class was generated from the following files: