diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-08-09 01:09:21 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-08-09 01:09:21 +0000 |
commit | 4fa93b7ce153a3834a7e189026e7451bcc19a34a (patch) | |
tree | baaebfaa3575677099f3dfba3b4ecf9af7dd2421 /lib/Transforms/Utils/LowerInvoke.cpp | |
parent | a2b552d0aec83b1d030b878a130c8fefafe4d3c3 (diff) |
Remove an instance where the 'unwind' instruction was created.
The 'unwind' instruction was acting essentially as a placeholder, because it
would be replaced at the end of this function by a branch to the "unwind
handler". The 'unwind' instruction is going away, so use 'unreachable' instead,
which serves the same purpose as a placeholder.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerInvoke.cpp')
-rw-r--r-- | lib/Transforms/Utils/LowerInvoke.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index eb3037fa92..3a034ecd90 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -406,6 +406,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { SmallVector<ReturnInst*,16> Returns; SmallVector<UnwindInst*,16> Unwinds; SmallVector<InvokeInst*,16> Invokes; + SmallVector<UnreachableInst*, 16> Unreachables; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) { @@ -486,9 +487,10 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Insert a load in the Catch block, and a switch on its value. By default, // we go to a block that just does an unwind (which is the correct action - // for a standard call). + // for a standard call). We insert an unreachable instruction here and + // modify the block to jump to the correct unwinding pad later. BasicBlock *UnwindBB = BasicBlock::Create(F.getContext(), "unwindbb", &F); - Unwinds.push_back(new UnwindInst(F.getContext(), UnwindBB)); + Unreachables.push_back(new UnreachableInst(F.getContext(), UnwindBB)); Value *CatchLoad = new LoadInst(InvokeNum, "invoke.num", true, CatchBB); SwitchInst *CatchSwitch = @@ -577,6 +579,12 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { Unwinds[i]->eraseFromParent(); } + // Replace all inserted unreachables with a branch to the unwind handler. + for (unsigned i = 0, e = Unreachables.size(); i != e; ++i) { + BranchInst::Create(UnwindHandler, Unreachables[i]); + Unreachables[i]->eraseFromParent(); + } + // Finally, for any returns from this function, if this function contains an // invoke, restore the old jmpbuf pointer to its input value. if (OldJmpBufPtr) { |