mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 21:34:23 +00:00
Fix quadratic behavior in InlineFunction by fetching the personality function of the callee once and not for every invoke in the caller.
The callee is usually smaller than the caller, too. This reduces the compile time of ARMDisassembler.cpp by 32% (Release build). It still takes ages to compile though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
94f2dc90a5
commit
30fe1ae20d
@ -924,39 +924,43 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the personality function from the callee if it contains a landing pad.
|
||||||
|
Value *CalleePersonality = 0;
|
||||||
|
for (Function::const_iterator I = CalledFunc->begin(), E = CalledFunc->end();
|
||||||
|
I != E; ++I)
|
||||||
|
if (const InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator())) {
|
||||||
|
const BasicBlock *BB = II->getUnwindDest();
|
||||||
|
// FIXME: This 'if/dyn_cast' here should become a normal 'cast' once
|
||||||
|
// the new EH system is in place.
|
||||||
|
if (const LandingPadInst *LP =
|
||||||
|
dyn_cast<LandingPadInst>(BB->getFirstNonPHI()))
|
||||||
|
CalleePersonality = LP->getPersonalityFn();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the personality function used by the landing pads of the caller. If it
|
// Find the personality function used by the landing pads of the caller. If it
|
||||||
// exists, then check to see that it matches the personality function used in
|
// exists, then check to see that it matches the personality function used in
|
||||||
// the callee.
|
// the callee.
|
||||||
for (Function::const_iterator
|
if (CalleePersonality)
|
||||||
I = Caller->begin(), E = Caller->end(); I != E; ++I)
|
for (Function::const_iterator I = Caller->begin(), E = Caller->end();
|
||||||
if (const InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator())) {
|
I != E; ++I)
|
||||||
const BasicBlock *BB = II->getUnwindDest();
|
if (const InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator())) {
|
||||||
// FIXME: This 'isa' here should become go away once the new EH system is
|
const BasicBlock *BB = II->getUnwindDest();
|
||||||
// in place.
|
// FIXME: This 'isa' here should become go away once the new EH system
|
||||||
if (!isa<LandingPadInst>(BB->getFirstNonPHI()))
|
// is in place.
|
||||||
continue;
|
if (!isa<LandingPadInst>(BB->getFirstNonPHI()))
|
||||||
const LandingPadInst *LP = cast<LandingPadInst>(BB->getFirstNonPHI());
|
continue;
|
||||||
const Value *CallerPersFn = LP->getPersonalityFn();
|
const LandingPadInst *LP = cast<LandingPadInst>(BB->getFirstNonPHI());
|
||||||
|
|
||||||
// If the personality functions match, then we can perform the
|
// If the personality functions match, then we can perform the
|
||||||
// inlining. Otherwise, we can't inline.
|
// inlining. Otherwise, we can't inline.
|
||||||
// TODO: This isn't 100% true. Some personality functions are proper
|
// TODO: This isn't 100% true. Some personality functions are proper
|
||||||
// supersets of others and can be used in place of the other.
|
// supersets of others and can be used in place of the other.
|
||||||
for (Function::const_iterator
|
if (LP->getPersonalityFn() != CalleePersonality)
|
||||||
I = CalledFunc->begin(), E = CalledFunc->end(); I != E; ++I)
|
return false;
|
||||||
if (const InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator())) {
|
|
||||||
const BasicBlock *BB = II->getUnwindDest();
|
|
||||||
// FIXME: This 'if/dyn_cast' here should become a normal 'cast' once
|
|
||||||
// the new EH system is in place.
|
|
||||||
if (const LandingPadInst *LP =
|
|
||||||
dyn_cast<LandingPadInst>(BB->getFirstNonPHI()))
|
|
||||||
if (CallerPersFn != LP->getPersonalityFn())
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get an iterator to the last basic block in the function, which will have
|
// Get an iterator to the last basic block in the function, which will have
|
||||||
// the new function inlined after it.
|
// the new function inlined after it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user