mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-13 01:15:32 +00:00
Add spliceFunction to the CallGraph interface. This allows users to efficiently
update a callGraph when performing the common operation of splicing the body to a new function and updating all callers (such as via RAUW). No users yet, though this is intended for DeadArgumentElimination as part of PR8887. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8e7f0d70c7
commit
9ad1cb59de
@ -138,6 +138,13 @@ public:
|
|||||||
/// not already exist.
|
/// not already exist.
|
||||||
CallGraphNode *getOrInsertFunction(const Function *F);
|
CallGraphNode *getOrInsertFunction(const Function *F);
|
||||||
|
|
||||||
|
/// spliceFunction - Replace the function represented by this node by another.
|
||||||
|
/// This does not rescan the body of the function, so it is suitable when
|
||||||
|
/// splicing the body of one function to another while also updating all
|
||||||
|
/// callers from the old function to the new.
|
||||||
|
///
|
||||||
|
void spliceFunction(const Function *From, const Function *To);
|
||||||
|
|
||||||
//===---------------------------------------------------------------------
|
//===---------------------------------------------------------------------
|
||||||
// Pass infrastructure interface glue code.
|
// Pass infrastructure interface glue code.
|
||||||
//
|
//
|
||||||
@ -163,8 +170,10 @@ protected:
|
|||||||
// CallGraphNode class definition.
|
// CallGraphNode class definition.
|
||||||
//
|
//
|
||||||
class CallGraphNode {
|
class CallGraphNode {
|
||||||
AssertingVH<Function> F;
|
friend class CallGraph;
|
||||||
|
|
||||||
|
AssertingVH<Function> F;
|
||||||
|
|
||||||
// CallRecord - This is a pair of the calling instruction (a call or invoke)
|
// CallRecord - This is a pair of the calling instruction (a call or invoke)
|
||||||
// and the callgraph node being called.
|
// and the callgraph node being called.
|
||||||
public:
|
public:
|
||||||
|
@ -230,6 +230,21 @@ Function *CallGraph::removeFunctionFromModule(CallGraphNode *CGN) {
|
|||||||
return F;
|
return F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// spliceFunction - Replace the function represented by this node by another.
|
||||||
|
/// This does not rescan the body of the function, so it is suitable when
|
||||||
|
/// splicing the body of the old function to the new while also updating all
|
||||||
|
/// callers from old to new.
|
||||||
|
///
|
||||||
|
void CallGraph::spliceFunction(const Function *From, const Function *To) {
|
||||||
|
assert(FunctionMap.count(From) && "No CallGraphNode for function!");
|
||||||
|
assert(!FunctionMap.count(To) &&
|
||||||
|
"Pointing CallGraphNode at a function that already exists");
|
||||||
|
FunctionMapTy::iterator I = FunctionMap.find(From);
|
||||||
|
I->second->F = const_cast<Function*>(To);
|
||||||
|
FunctionMap[To] = I->second;
|
||||||
|
FunctionMap.erase(I);
|
||||||
|
}
|
||||||
|
|
||||||
// getOrInsertFunction - This method is identical to calling operator[], but
|
// getOrInsertFunction - This method is identical to calling operator[], but
|
||||||
// it will insert a new CallGraphNode for the specified function if one does
|
// it will insert a new CallGraphNode for the specified function if one does
|
||||||
// not already exist.
|
// not already exist.
|
||||||
@ -276,7 +291,6 @@ void CallGraphNode::removeCallEdgeFor(CallSite CS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// removeAnyCallEdgeTo - This method removes any call edges from this node to
|
// removeAnyCallEdgeTo - This method removes any call edges from this node to
|
||||||
// the specified callee function. This takes more time to execute than
|
// the specified callee function. This takes more time to execute than
|
||||||
// removeCallEdgeTo, so it should not be used unless necessary.
|
// removeCallEdgeTo, so it should not be used unless necessary.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user