LLVM  14.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 ()
 } More...
 
 ~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). More...
 
void initialize (LazyCallGraph &LCG, LazyCallGraph::SCC &SCC, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR)
 
bool finalize ()
 } More...
 
void removeFunction (Function &Fn)
 Remove Fn from the call graph. More...
 
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. More...
 
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. More...
 
void replaceFunctionWith (Function &OldFn, Function &NewFn)
 Replace OldFn in the call graph (and SCC) with NewFn. More...
 
void removeCallSite (CallBase &CS)
 Remove the call site CS from the call graph. More...
 
bool replaceCallSite (CallBase &OldCS, CallBase &NewCS)
 Replace OldCS with the new call site NewCS. More...
 

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 28 of file CallGraphUpdater.h.

Constructor & Destructor Documentation

◆ CallGraphUpdater()

llvm::CallGraphUpdater::CallGraphUpdater ( )
inline

}

Definition at line 56 of file CallGraphUpdater.h.

◆ ~CallGraphUpdater()

llvm::CallGraphUpdater::~CallGraphUpdater ( )
inline

Definition at line 57 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 62 of file CallGraphUpdater.h.

Referenced by llvm::OpenMPOptCGSCCPass::run(), and llvm::AttributorCGSCCPass::run().

◆ initialize() [2/2]

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

◆ reanalyzeFunction()

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 87 of file CallGraphUpdater.cpp.

References llvm::LazyCallGraph::get(), llvm::CallGraph::getOrInsertFunction(), llvm::LazyCallGraph::lookupSCC(), N, llvm::CallGraph::populateCallGraphNode(), llvm::CallGraphNode::removeAllCalledFunctions(), and llvm::updateCGAndAnalysisManagerForCGSCCPass().

Referenced by runAttributorOnFunctions().

◆ 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 99 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 160 of file CallGraphUpdater.cpp.

References llvm::CallBase::getCaller(), and llvm::CallGraphNode::removeCallEdgeFor().

Referenced by DeleteBasicBlock(), and 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 143 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 123 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: