Go to the documentation of this file.
25 if (!DeadFunctionsInComdats.empty()) {
27 DeadFunctions.append(DeadFunctionsInComdats.begin(),
28 DeadFunctionsInComdats.end());
34 for (
Function *DeadFn : DeadFunctions) {
35 DeadFn->removeDeadConstantUsers();
43 for (
Function *DeadFn : DeadFunctions) {
46 "References should have been handled by now");
52 for (
Function *DeadFn : DeadFunctions) {
56 if (LCG && !ReplacedFunctions.count(DeadFn)) {
60 assert(DeadSCC && DeadSCC->size() == 1 &&
61 &DeadSCC->begin()->getFunction() == DeadFn);
62 auto &DeadRC = DeadSCC->getOuterRefSCC();
68 FAM.
clear(*DeadFn, DeadFn->getName());
69 AM->
clear(*DeadSCC, DeadSCC->getName());
79 DeadFn->eraseFromParent();
83 bool Changed = !DeadFunctions.empty();
84 DeadFunctionsInComdats.clear();
85 DeadFunctions.clear();
113 DeadFunctionsInComdats.push_back(&DeadFn);
115 DeadFunctions.push_back(&DeadFn);
118 if (CG && !ReplacedFunctions.count(&DeadFn)) {
127 ReplacedFunctions.insert(&OldFn);
155 return CR.first && *CR.first == &OldCS;
void removeAnyCallEdgeTo(CallGraphNode *Callee)
Removes all call edges from this node to the specified callee function.
This is an optimization pass for GlobalISel generic memory operations.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
SmallPtrSetImpl< LazyCallGraph::SCC * > & InvalidatedSCCs
The set of invalidated SCCs which should be skipped if they are found in CWorklist.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
bool replaceCallSite(CallBase &OldCS, CallBase &NewCS)
Replace OldCS with the new call site NewCS.
std::pair< Optional< WeakTrackingVH >, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called.
void removeCallEdgeFor(CallBase &Call)
Removes the edge in the node for the specified call site.
void removeDeadFunction(Function &F)
Remove a dead function from the call graph (typically to delete it).
FunctionAnalysisManager FAM
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist.
An SCC of the call graph.
unsigned getNumReferences() const
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee...
void removeCallSite(CallBase &CS)
Remove the call site CS from the call graph.
(vector float) vec_cmpeq(*A, *B) C
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
void clear(IRUnitT &IR, llvm::StringRef Name)
Clear any cached analysis results for a single unit of IR.
void ReplaceNode(CallGraphNode *Old, CallGraphNode *New)
ReplaceNode - This informs the SCC and the pass manager that the specified Old node has been deleted,...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A node in the call graph for a module.
SCC * lookupSCC(Node &N) const
Lookup a function's SCC in the graph.
Function * getCaller()
Helper to get the caller (the parent function).
void ReplaceExternalCallEdge(CallGraphNode *Old, CallGraphNode *New)
Old node has been deleted, and New is to be used in its place, update the ExternalCallingNode.
Node & get(Function &F)
Get a graph node for a given function, scanning it to populate the graph data as necessary.
void populateCallGraphNode(CallGraphNode *CGN)
Populate CGN based on the calls inside the associated function.
void removeAllCalledFunctions()
Removes all edges from this CallGraphNode to any functions it calls.
void addSplitFunction(Function &OriginalFunction, Function &NewFunction)
Add a new function split/outlined from an existing function.
void DeleteNode(CallGraphNode *Old)
DeleteNode - This informs the SCC and the pass manager that the specified Old node has been deleted.
void filterDeadComdatFunctions(SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.
void setLinkage(LinkageTypes LT)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning 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 th...
A node in the call graph.
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
void addToCallGraph(Function *F)
Add a function to the call graph, and link the node to all of the functions that it calls.
void replaceNodeFunction(Node &N, Function &NewF)
Directly replace a node's function with a new function.
void replaceFunctionWith(Function &OldFn, Function &NewFn)
Replace OldFn in the call graph (and SCC) with NewFn.
LazyCallGraph::SCC & updateCGAndAnalysisManagerForCGSCCPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)
Helper to update the call graph after running a CGSCC pass.
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
@ ExternalLinkage
Externally visible function.
void removeFunction(Function &Fn)
Remove Fn from the call graph.
RefSCC & getOuterRefSCC() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A container for analyses that lazily runs them and caches their results.
void reanalyzeFunction(Function &Fn)
After an CGSCC pass changes a function in ways that affect the call graph, this method can be called ...
A proxy from a FunctionAnalysisManager to an SCC.
SmallPtrSetImpl< LazyCallGraph::RefSCC * > & InvalidatedRefSCCs
The set of invalidated RefSCCs which should be skipped if they are found in RCWorklist.
void stealCalledFunctionsFrom(CallGraphNode *N)
Moves all the callee information from N to this node.
void replaceCallEdge(CallBase &Call, CallBase &NewCall, CallGraphNode *NewNode)
Replaces the edge in the node for the specified call site with a new one.