mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
Fix compilation of 126.gcc: intrinsic functions cannot throw, so they are not
allowed in invoke instructions. Thus, if we are inlining a call to an intrinsic function into an invoke site, we don't need to turn the call into an invoke! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11384 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0db085baec
commit
494b6920b0
@ -123,34 +123,39 @@ bool llvm::InlineFunction(CallSite CS) {
|
|||||||
// We only need to check for function calls: inlined invoke instructions
|
// We only need to check for function calls: inlined invoke instructions
|
||||||
// require no special handling...
|
// require no special handling...
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
||||||
// Convert this function call into an invoke instruction...
|
// Convert this function call into an invoke instruction... if it's
|
||||||
|
// not an intrinsic function call (which are known to not throw).
|
||||||
|
if (CI->getCalledFunction() &&
|
||||||
|
CI->getCalledFunction()->getIntrinsicID()) {
|
||||||
|
++I;
|
||||||
|
} else {
|
||||||
|
// First, split the basic block...
|
||||||
|
BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
|
||||||
|
|
||||||
|
// Next, create the new invoke instruction, inserting it at the end
|
||||||
|
// of the old basic block.
|
||||||
|
InvokeInst *II =
|
||||||
|
new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
|
||||||
|
std::vector<Value*>(CI->op_begin()+1, CI->op_end()),
|
||||||
|
CI->getName(), BB->getTerminator());
|
||||||
|
|
||||||
// First, split the basic block...
|
// Make sure that anything using the call now uses the invoke!
|
||||||
BasicBlock *Split = BB->splitBasicBlock(CI, CI->getName()+".noexc");
|
CI->replaceAllUsesWith(II);
|
||||||
|
|
||||||
// Next, create the new invoke instruction, inserting it at the end
|
// Delete the unconditional branch inserted by splitBasicBlock
|
||||||
// of the old basic block.
|
BB->getInstList().pop_back();
|
||||||
InvokeInst *II =
|
Split->getInstList().pop_front(); // Delete the original call
|
||||||
new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
|
|
||||||
std::vector<Value*>(CI->op_begin()+1, CI->op_end()),
|
// Update any PHI nodes in the exceptional block to indicate that
|
||||||
CI->getName(), BB->getTerminator());
|
// there is now a new entry in them.
|
||||||
|
unsigned i = 0;
|
||||||
// Make sure that anything using the call now uses the invoke!
|
for (BasicBlock::iterator I = InvokeDest->begin();
|
||||||
CI->replaceAllUsesWith(II);
|
PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i)
|
||||||
|
PN->addIncoming(InvokeDestPHIValues[i], BB);
|
||||||
// Delete the unconditional branch inserted by splitBasicBlock
|
|
||||||
BB->getInstList().pop_back();
|
// This basic block is now complete, start scanning the next one.
|
||||||
Split->getInstList().pop_front(); // Delete the original call
|
break;
|
||||||
|
}
|
||||||
// Update any PHI nodes in the exceptional block to indicate that
|
|
||||||
// there is now a new entry in them.
|
|
||||||
unsigned i = 0;
|
|
||||||
for (BasicBlock::iterator I = InvokeDest->begin();
|
|
||||||
PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i)
|
|
||||||
PN->addIncoming(InvokeDestPHIValues[i], BB);
|
|
||||||
|
|
||||||
// This basic block is now complete, start scanning the next one.
|
|
||||||
break;
|
|
||||||
} else {
|
} else {
|
||||||
++I;
|
++I;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user