mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
When PruneEH turned an invoke into an ordinary
call (thus changing the call site) it didn't inform the callgraph about this. But the call site does matter - as shown by the testcase, the callgraph become invalid after the inliner ran (with an edge between two functions simply missing), resulting in wrong deductions by GlobalsModRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3b217c6f5c
commit
fec2c2bf5e
@ -235,6 +235,11 @@ public:
|
||||
/// removeCallEdgeTo, so it should not be used unless necessary.
|
||||
void removeAnyCallEdgeTo(CallGraphNode *Callee);
|
||||
|
||||
/// replaceCallSite - Make the edge in the node for Old CallSite be for
|
||||
/// New CallSite instead. Note that this method takes linear time, so it
|
||||
/// should be used sparingly.
|
||||
void replaceCallSite(CallSite Old, CallSite New);
|
||||
|
||||
friend class CallGraph;
|
||||
|
||||
// CallGraphNode ctor - Create a node for the specified function.
|
||||
|
@ -297,7 +297,7 @@ void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
|
||||
/// should be used sparingly.
|
||||
void CallGraphNode::removeCallEdgeFor(CallSite CS) {
|
||||
for (unsigned i = CalledFunctions.size(); ; --i) {
|
||||
assert(i && "Cannot find callee to remove!");
|
||||
assert(i && "Cannot find callsite to remove!");
|
||||
if (CalledFunctions[i-1].first == CS) {
|
||||
CalledFunctions.erase(CalledFunctions.begin()+i-1);
|
||||
return;
|
||||
@ -318,5 +318,18 @@ void CallGraphNode::removeAnyCallEdgeTo(CallGraphNode *Callee) {
|
||||
}
|
||||
}
|
||||
|
||||
/// replaceCallSite - Make the edge in the node for Old CallSite be for
|
||||
/// New CallSite instead. Note that this method takes linear time, so it
|
||||
/// should be used sparingly.
|
||||
void CallGraphNode::replaceCallSite(CallSite Old, CallSite New) {
|
||||
for (unsigned i = CalledFunctions.size(); ; --i) {
|
||||
assert(i && "Cannot find callsite to replace!");
|
||||
if (CalledFunctions[i-1].first == Old) {
|
||||
CalledFunctions[i-1].first = New;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enuse that users of CallGraph.h also link with this file
|
||||
DEFINING_FILE_FOR(CallGraph)
|
||||
|
@ -156,6 +156,9 @@ bool PruneEH::runOnSCC(const std::vector<CallGraphNode *> &SCC) {
|
||||
// function if we have invokes to non-unwinding functions or code after calls to
|
||||
// no-return functions.
|
||||
bool PruneEH::SimplifyFunction(Function *F) {
|
||||
CallGraph &CG = getAnalysis<CallGraph>();
|
||||
CallGraphNode *CGN = CG[F];
|
||||
|
||||
bool MadeChange = false;
|
||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator()))
|
||||
@ -174,6 +177,9 @@ bool PruneEH::SimplifyFunction(Function *F) {
|
||||
BasicBlock *UnwindBlock = II->getUnwindDest();
|
||||
UnwindBlock->removePredecessor(II->getParent());
|
||||
|
||||
// Fix up the call graph.
|
||||
CGN->replaceCallSite(II, Call);
|
||||
|
||||
// Insert a branch to the normal destination right before the
|
||||
// invoke.
|
||||
BranchInst::Create(II->getNormalDest(), II);
|
||||
|
1438
test/Transforms/PruneEH/2008-09-05-CGUpdate.ll
Normal file
1438
test/Transforms/PruneEH/2008-09-05-CGUpdate.ll
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user