LLVM: lib/Transforms/Utils/CallGraphUpdater.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
18
19using namespace llvm;
20
22 if (!DeadFunctionsInComdats.empty()) {
24 DeadFunctions.append(DeadFunctionsInComdats.begin(),
25 DeadFunctionsInComdats.end());
26 }
27
28
29
30 for (Function *DeadFn : DeadFunctions) {
31 DeadFn->removeDeadConstantUsers();
32 DeadFn->replaceAllUsesWith(PoisonValue::get(DeadFn->getType()));
33
34 if (LCG && !ReplacedFunctions.count(DeadFn)) {
35
37 auto *DeadSCC = LCG->lookupSCC(N);
38 assert(DeadSCC && DeadSCC->size() == 1 &&
39 &DeadSCC->begin()->getFunction() == DeadFn);
40
41 FAM->clear(*DeadFn, DeadFn->getName());
42 AM->clear(*DeadSCC, DeadSCC->getName());
43 LCG->markDeadFunction(*DeadFn);
44
45
46
47 UR->InvalidatedSCCs.insert(LCG->lookupSCC(N));
48 UR->DeadFunctions.push_back(DeadFn);
49 } else {
50
51
52
53
54 DeadFn->eraseFromParent();
55 }
56 }
57
58 bool Changed = !DeadFunctions.empty();
59 DeadFunctionsInComdats.clear();
60 DeadFunctions.clear();
62}
63
71
74 if (LCG)
75 LCG->addSplitFunction(OriginalFn, NewFn);
76}
77
82 DeadFunctionsInComdats.push_back(&DeadFn);
83 else
84 DeadFunctions.push_back(&DeadFn);
85
86 if (FAM)
87 FAM->clear(DeadFn, DeadFn.getName());
88}
89
92 ReplacedFunctions.insert(&OldFn);
93 if (LCG) {
94
96 SCC->getOuterRefSCC().replaceNodeFunction(OldLCGN, NewFn);
97 }
99}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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...
Definition CallGraphUpdater.cpp:72
LLVM_ABI void removeFunction(Function &Fn)
Remove Fn from the call graph.
Definition CallGraphUpdater.cpp:78
LLVM_ABI void replaceFunctionWith(Function &OldFn, Function &NewFn)
Replace OldFn in the call graph (and SCC) with NewFn.
Definition CallGraphUpdater.cpp:90
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 ...
Definition CallGraphUpdater.cpp:64
LLVM_ABI bool finalize()
}
Definition CallGraphUpdater.cpp:21
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
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.
An SCC of the call graph.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
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.