mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Move the personality function from LandingPadInst to Function
The personality routine currently lives in the LandingPadInst. This isn't desirable because: - All LandingPadInsts in the same function must have the same personality routine. This means that each LandingPadInst beyond the first has an operand which produces no additional information. - There is ongoing work to introduce EH IR constructs other than LandingPadInst. Moving the personality routine off of any one particular Instruction and onto the parent function seems a lot better than have N different places a personality function can sneak onto an exceptional function. Differential Revision: http://reviews.llvm.org/D10429 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -949,35 +949,23 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
|
||||
}
|
||||
|
||||
// Get the personality function from the callee if it contains a landing pad.
|
||||
Value *CalleePersonality = nullptr;
|
||||
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();
|
||||
const LandingPadInst *LP = BB->getLandingPadInst();
|
||||
CalleePersonality = LP->getPersonalityFn();
|
||||
break;
|
||||
}
|
||||
Constant *CalledPersonality =
|
||||
CalledFunc->hasPersonalityFn() ? CalledFunc->getPersonalityFn() : nullptr;
|
||||
|
||||
// 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
|
||||
// the callee.
|
||||
if (CalleePersonality) {
|
||||
for (Function::const_iterator I = Caller->begin(), E = Caller->end();
|
||||
I != E; ++I)
|
||||
if (const InvokeInst *II = dyn_cast<InvokeInst>(I->getTerminator())) {
|
||||
const BasicBlock *BB = II->getUnwindDest();
|
||||
const LandingPadInst *LP = BB->getLandingPadInst();
|
||||
|
||||
// If the personality functions match, then we can perform the
|
||||
// inlining. Otherwise, we can't inline.
|
||||
// TODO: This isn't 100% true. Some personality functions are proper
|
||||
// supersets of others and can be used in place of the other.
|
||||
if (LP->getPersonalityFn() != CalleePersonality)
|
||||
return false;
|
||||
|
||||
break;
|
||||
}
|
||||
Constant *CallerPersonality =
|
||||
Caller->hasPersonalityFn() ? Caller->getPersonalityFn() : nullptr;
|
||||
if (CalledPersonality) {
|
||||
if (!CallerPersonality)
|
||||
Caller->setPersonalityFn(CalledPersonality);
|
||||
// If the personality functions match, then we can perform the
|
||||
// inlining. Otherwise, we can't inline.
|
||||
// TODO: This isn't 100% true. Some personality functions are proper
|
||||
// supersets of others and can be used in place of the other.
|
||||
else if (CalledPersonality != CallerPersonality)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get an iterator to the last basic block in the function, which will have
|
||||
|
Reference in New Issue
Block a user