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;
This file provides interfaces used to manipulate a call graph, regardless if it is a "old style" Call...
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
FunctionAnalysisManager FAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
void clear(IRUnitT &IR, llvm::StringRef Name)
Clear any cached analysis results for a single unit of IR.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Function * getCaller()
Helper to get the caller (the parent function).
A node in the call graph for a module.
void removeCallEdgeFor(CallBase &Call)
Removes the edge in the node for the specified call site.
void replaceCallEdge(CallBase &Call, CallBase &NewCall, CallGraphNode *NewNode)
Replaces the edge in the node for the specified call site with a new one.
void stealCalledFunctionsFrom(CallGraphNode *N)
Moves all the callee information from N to this node.
void removeAllCalledFunctions()
Removes all edges from this CallGraphNode to any functions it calls.
unsigned getNumReferences() const
Returns the number of other CallGraphNodes in this CallGraph that reference this node in their callee...
void removeAnyCallEdgeTo(CallGraphNode *Callee)
Removes all call edges from this node to the specified callee function.
std::pair< std::optional< WeakTrackingVH >, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called.
void ReplaceNode(CallGraphNode *Old, CallGraphNode *New)
ReplaceNode - This informs the SCC and the pass manager that the specified Old node has been deleted,...
void DeleteNode(CallGraphNode *Old)
DeleteNode - This informs the SCC and the pass manager that the specified Old node has been deleted.
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...
void removeFunction(Function &Fn)
Remove Fn from the call graph.
void removeCallSite(CallBase &CS)
Remove the call site CS from the call graph.
void replaceFunctionWith(Function &OldFn, Function &NewFn)
Replace OldFn in the call graph (and SCC) with NewFn.
void reanalyzeFunction(Function &Fn)
After an CGSCC pass changes a function in ways that affect the call graph, this method can be called ...
bool replaceCallSite(CallBase &OldCS, CallBase &NewCS)
Replace OldCS with the new call site NewCS.
Function * removeFunctionFromModule(CallGraphNode *CGN)
Unlink the function from this module, returning it.
void populateCallGraphNode(CallGraphNode *CGN)
Populate CGN based on the calls inside the associated function.
void addToCallGraph(Function *F)
Add a function to the call graph, and link the node to all of the functions that it calls.
CallGraphNode * getOrInsertFunction(const Function *F)
Similar to operator[], but this will insert a new CallGraphNode for F if one does not already exist.
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
void ReplaceExternalCallEdge(CallGraphNode *Old, CallGraphNode *New)
Old node has been deleted, and New is to be used in its place, update the ExternalCallingNode.
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
A proxy from a FunctionAnalysisManager to an SCC.
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
void setLinkage(LinkageTypes LT)
@ ExternalLinkage
Externally visible function.
A node in the call graph.
void replaceNodeFunction(Node &N, Function &NewF)
Directly replace a node's function with a new function.
An SCC of the call graph.
RefSCC & getOuterRefSCC() const
void removeDeadFunction(Function &F)
Remove a dead function from the call graph (typically to delete it).
void addSplitFunction(Function &OriginalFunction, Function &NewFunction)
Add a new function split/outlined from an existing function.
Node & get(Function &F)
Get a graph node for a given function, scanning it to populate the graph data as necessary.
SCC * lookupSCC(Node &N) const
Lookup a function's SCC in the graph.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
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.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
void filterDeadComdatFunctions(SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.
SmallPtrSetImpl< LazyCallGraph::SCC * > & InvalidatedSCCs
The set of invalidated SCCs which should be skipped if they are found in CWorklist.
SmallPtrSetImpl< LazyCallGraph::RefSCC * > & InvalidatedRefSCCs
The set of invalidated RefSCCs which should be skipped if they are found in RCWorklist.