mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-20 11:29:24 +00:00
Fix a performance regression from the CPR patch, simplify code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14974 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
96940cb522
commit
8919cccc3d
@ -170,28 +170,20 @@ bool Inliner::doFinalization(CallGraph &CG) {
|
|||||||
CallGraphNode *CGN = I->second;
|
CallGraphNode *CGN = I->second;
|
||||||
Function *F = CGN ? CGN->getFunction() : 0;
|
Function *F = CGN ? CGN->getFunction() : 0;
|
||||||
|
|
||||||
// If the only remaining use of the function is a dead constant
|
// If the only remaining users of the function are dead constants,
|
||||||
// pointer ref, remove it.
|
// remove them.
|
||||||
if (F && F->hasOneUse())
|
if (F) F->removeDeadConstantUsers();
|
||||||
if (Function *GV = dyn_cast<Function>(F->use_back()))
|
|
||||||
if (GV->removeDeadConstantUsers()) {
|
|
||||||
if (F->hasInternalLinkage()) {
|
|
||||||
// There *MAY* be an edge from the external call node to this
|
|
||||||
// function. If so, remove it.
|
|
||||||
CallGraphNode *EN = CG.getExternalCallingNode();
|
|
||||||
CallGraphNode::iterator I = std::find(EN->begin(), EN->end(), CGN);
|
|
||||||
if (I != EN->end()) EN->removeCallEdgeTo(CGN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
|
if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
|
||||||
F->use_empty()) {
|
F->use_empty()) {
|
||||||
|
|
||||||
// Remove any call graph edges from the function to its callees.
|
// Remove any call graph edges from the function to its callees.
|
||||||
while (CGN->begin() != CGN->end())
|
while (CGN->begin() != CGN->end())
|
||||||
CGN->removeCallEdgeTo(*(CGN->end()-1));
|
CGN->removeCallEdgeTo(*(CGN->end()-1));
|
||||||
|
|
||||||
// If the function has external linkage (basically if it's a linkonce
|
// If the function has external linkage (basically if it's a linkonce
|
||||||
// function) remove the edge from the external node to the callee node.
|
// function) remove the edge from the external node to the callee
|
||||||
|
// node.
|
||||||
if (!F->hasInternalLinkage())
|
if (!F->hasInternalLinkage())
|
||||||
CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
|
CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user