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