mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
Revert r176154 in favor of a better approach.
Code generation makes some basic assumptions about the IR it's been given. In particular, if there is only one 'invoke' in the function, then that invoke won't be going away. However, with the advent of the `llvm.donothing' intrinsic, those invokes may go away. If all of them go away, the landing pad no longer has any users. This confuses the back-end, which asserts. This happens with SjLj exceptions, because that's the model that modifies the IR based on there being invokes, etc. in the function. Remove any invokes of `llvm.donothing' during SjLj EH preparation. This will give us a CFG that the back-end won't be confused about. If all of the invokes in a function are removed, then the SjLj EH prepare pass won't insert the bogus code the relies upon the invokes being there. <rdar://problem/13228754&13316637> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176677 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -379,13 +379,22 @@ void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F,
|
||||
/// the function context and marking the call sites with the appropriate
|
||||
/// values. These values are used by the DWARF EH emitter.
|
||||
bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
|
||||
SmallVector<ReturnInst*, 16> Returns;
|
||||
SmallVector<InvokeInst*, 16> Invokes;
|
||||
SmallVector<ReturnInst*, 16> Returns;
|
||||
SmallVector<InvokeInst*, 16> Invokes;
|
||||
SmallSetVector<LandingPadInst*, 16> LPads;
|
||||
|
||||
// Look through the terminators of the basic blocks to find invokes.
|
||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) {
|
||||
if (Function *Callee = II->getCalledFunction())
|
||||
if (Callee->isIntrinsic() &&
|
||||
Callee->getIntrinsicID() == Intrinsic::donothing) {
|
||||
// Remove the NOP invoke.
|
||||
BranchInst::Create(II->getNormalDest(), II);
|
||||
II->eraseFromParent();
|
||||
continue;
|
||||
}
|
||||
|
||||
Invokes.push_back(II);
|
||||
LPads.insert(II->getUnwindDest()->getLandingPadInst());
|
||||
} else if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
|
||||
|
Reference in New Issue
Block a user