22 if (!DeadFunctionsInComdats.empty()) {
24 for (
Function *DeadFn : DeadFunctionsInComdats)
26 DeadFunctions.append(DeadFunctionsInComdats.begin(),
27 DeadFunctionsInComdats.end());
32 for (
Function *DeadFn : DeadFunctions) {
33 DeadFn->removeDeadConstantUsers();
37 if (DeadFn->isUsedByMetadata())
41 if (LCG && !ReplacedFunctions.count(DeadFn)) {
44 auto *DeadSCC = LCG->lookupSCC(
N);
45 assert(DeadSCC && DeadSCC->size() == 1 &&
46 &DeadSCC->begin()->getFunction() == DeadFn);
48 FAM->clear(*DeadFn, DeadFn->getName());
49 AM->clear(*DeadSCC, DeadSCC->getName());
50 LCG->markDeadFunction(*DeadFn);
54 UR->InvalidatedSCCs.insert(LCG->lookupSCC(
N));
55 UR->DeadFunctions.push_back(DeadFn);
61 DeadFn->eraseFromParent();
65 bool Changed = !DeadFunctions.empty();
66 DeadFunctionsInComdats.clear();
67 DeadFunctions.clear();
88 if (!
N->lookup(RefereeN))
89 LCG->lookupRefSCC(
N)->insertTrivialRefEdge(
N, RefereeN);
96 LCG->addSplitFunction(OriginalFn, NewFn);
104 DeadFunctionsInComdats.push_back(&DeadFn);
107 DeadFunctions.push_back(&DeadFn);
116 ReplacedFunctions.insert(&OldFn);
120 SCC->getOuterRefSCC().replaceNodeFunction(OldLCGN, NewFn);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file provides interfaces used to manipulate a call graph, regardless if it is a "old style" Call...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
LLVM_ABI 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...
LLVM_ABI void addReferences(Function &Fn, Constant &C)
Add reference edges from Fn to the functions referenced by C, which is newly used in Fn.
LLVM_ABI void removeFunction(Function &Fn)
Remove Fn from the call graph.
LLVM_ABI void replaceFunctionWith(Function &OldFn, Function &NewFn)
Replace OldFn in the call graph (and SCC) with NewFn.
LLVM_ABI void reanalyzeFunction(Function &Fn)
After an CGSCC pass changes a function in ways that affect the call graph, this method can be called ...
LLVM_ABI bool finalize()
}
This is an important base class in LLVM.
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
A node in the call graph.
An SCC of the call graph.
static LLVM_ABI void visitReferences(SmallVectorImpl< Constant * > &Worklist, SmallPtrSetImpl< Constant * > &Visited, function_ref< void(Function &)> Callback)
Recursively visits the defined functions whose address is reachable from every constant in the Workli...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void makeFunctionBodyUnreachable(Function &F)
Replace the body of the dead function F with a single unreachable block.
LLVM_ABI 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.
LLVM_ABI void filterDeadComdatFunctions(SmallVectorImpl< Function * > &DeadComdatFunctions)
Filter out potentially dead comdat functions where other entries keep the entire comdat group alive.