diff options
| author | Reid Kleckner <reid@kleckner.net> | 2015-04-24 16:22:19 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2015-04-24 16:22:19 +0000 |
| commit | 2c3ccaacb7b279ee030a0a911e987a92d491b27c (patch) | |
| tree | 1e4bbec9e1fa4964757f7264c11c0fe00a7dd644 /llvm/lib/CodeGen/WinEHPrepare.cpp | |
| parent | c08ab8e6e4559b6ba5bc16f70c75da86bd278a4f (diff) | |
| download | bcm5719-llvm-2c3ccaacb7b279ee030a0a911e987a92d491b27c.tar.gz bcm5719-llvm-2c3ccaacb7b279ee030a0a911e987a92d491b27c.zip | |
[WinEH] Split the landingpad BB instead of cloning it
This means we don't have to RAUW the landingpad instruction and
landingpad BB, which is a nice win.
llvm-svn: 235725
Diffstat (limited to 'llvm/lib/CodeGen/WinEHPrepare.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/WinEHPrepare.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 09f3e13252b..8a0fb7fd1bc 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -670,25 +670,13 @@ bool WinEHPrepare::prepareExceptionHandlers( outlineHandler(Action, &F, LPad, StartBB, FrameVarInfo); } - // Replace the landing pad with a new llvm.eh.action based landing pad. - BasicBlock *NewLPadBB = BasicBlock::Create(Context, "lpad", &F, LPadBB); - assert(!isa<PHINode>(LPadBB->begin())); - auto *NewLPad = cast<LandingPadInst>(LPad->clone()); - NewLPadBB->getInstList().push_back(NewLPad); - while (!pred_empty(LPadBB)) { - auto *pred = *pred_begin(LPadBB); - InvokeInst *Invoke = cast<InvokeInst>(pred->getTerminator()); - Invoke->setUnwindDest(NewLPadBB); - } - - // Replace the mapping of any nested landing pad that previously mapped - // to this landing pad with a referenced to the cloned version. - for (auto &LPadPair : NestedLPtoOriginalLP) { - const LandingPadInst *OriginalLPad = LPadPair.second; - if (OriginalLPad == LPad) { - LPadPair.second = NewLPad; - } - } + // Split the block after the landingpad instruction so that it is just a + // call to llvm.eh.actions followed by indirectbr. + assert(!isa<PHINode>(LPadBB->begin()) && "lpad phi not removed"); + LPadBB->splitBasicBlock(LPad->getNextNode(), + LPadBB->getName() + ".prepsplit"); + // Erase the branch inserted by the split so we can insert indirectbr. + LPadBB->getTerminator()->eraseFromParent(); // Replace all extracted values with undef and ultimately replace the // landingpad with undef. @@ -733,7 +721,7 @@ bool WinEHPrepare::prepareExceptionHandlers( ActionArgs.push_back(Action->getHandlerBlockOrFunc()); } CallInst *Recover = - CallInst::Create(ActionIntrin, ActionArgs, "recover", NewLPadBB); + CallInst::Create(ActionIntrin, ActionArgs, "recover", LPadBB); // Add an indirect branch listing possible successors of the catch handlers. SetVector<BasicBlock *> ReturnTargets; @@ -744,7 +732,7 @@ bool WinEHPrepare::prepareExceptionHandlers( } } IndirectBrInst *Branch = - IndirectBrInst::Create(Recover, ReturnTargets.size(), NewLPadBB); + IndirectBrInst::Create(Recover, ReturnTargets.size(), LPadBB); for (BasicBlock *Target : ReturnTargets) Branch->addDestination(Target); } // End for each landingpad |

