diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-10-13 22:08:17 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-10-13 22:08:17 +0000 |
commit | eba62796cb9bb9e4856b4067a0d0117033cb3c1d (patch) | |
tree | b5fa7004ad484f89e78ee39e04639aa41e5d6169 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | ac93f649fa9449e56527ba8d3b10bf1c73d92af4 (diff) | |
download | bcm5719-llvm-eba62796cb9bb9e4856b4067a0d0117033cb3c1d.tar.gz bcm5719-llvm-eba62796cb9bb9e4856b4067a0d0117033cb3c1d.zip |
[InlineFunction] Correctly inline TerminatePadInst
We forgot to append the terminatepad's arguments which resulted in us
treating the old terminatepad as an argument to the new terminatepad
causing us to crash immediately. Instead, add the old terminatepad's
arguments to the new terminatepad.
This fixes PR25155.
llvm-svn: 250234
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 9d45788d94b..5539a26b3f3 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -341,9 +341,10 @@ static void HandleInlinedEHPad(InvokeInst *II, BasicBlock *FirstNewBlock, } else if (auto *TPI = dyn_cast<TerminatePadInst>(I)) { if (TPI->unwindsToCaller()) { SmallVector<Value *, 3> TerminatePadArgs; - for (Value *Operand : TPI->operands()) - TerminatePadArgs.push_back(Operand); - TerminatePadInst::Create(TPI->getContext(), UnwindDest, TPI); + for (Value *ArgOperand : TPI->arg_operands()) + TerminatePadArgs.push_back(ArgOperand); + TerminatePadInst::Create(TPI->getContext(), UnwindDest, + TerminatePadArgs, TPI); TPI->eraseFromParent(); UpdatePHINodes(&*BB); } @@ -1048,13 +1049,17 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, // Get the personality function from the callee if it contains a landing pad. Constant *CalledPersonality = - CalledFunc->hasPersonalityFn() ? CalledFunc->getPersonalityFn() : nullptr; + CalledFunc->hasPersonalityFn() + ? CalledFunc->getPersonalityFn()->stripPointerCasts() + : 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. Constant *CallerPersonality = - Caller->hasPersonalityFn() ? Caller->getPersonalityFn() : nullptr; + Caller->hasPersonalityFn() + ? Caller->getPersonalityFn()->stripPointerCasts() + : nullptr; if (CalledPersonality) { if (!CallerPersonality) Caller->setPersonalityFn(CalledPersonality); |