diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2015-04-24 23:10:38 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2015-04-24 23:10:38 +0000 |
commit | 5dacfd8b8a219c10e3e241f08e5ef969e6ac4a27 (patch) | |
tree | 2329161af42a4be54d7a313301e5fcee684324cd /llvm | |
parent | 7d831a5731e9b4002822fb2bdfbbd26184480767 (diff) | |
download | bcm5719-llvm-5dacfd8b8a219c10e3e241f08e5ef969e6ac4a27.tar.gz bcm5719-llvm-5dacfd8b8a219c10e3e241f08e5ef969e6ac4a27.zip |
[WinEH] Find correct cloned entry block for outlined handler functions.
llvm-svn: 235789
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/CodeGen/WinEHPrepare.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 072aea77900..1325821d498 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -1179,10 +1179,19 @@ bool WinEHPrepare::outlineHandler(ActionHandler *Action, Function *SrcFn, /*ModuleLevelChanges=*/false, Returns, "", &OutlinedFunctionInfo, Director.get()); - // Move all the instructions in the first cloned block into our entry block. - BasicBlock *FirstClonedBB = std::next(Function::iterator(Entry)); - Entry->getInstList().splice(Entry->end(), FirstClonedBB->getInstList()); - FirstClonedBB->eraseFromParent(); + // Move all the instructions in the cloned "entry" block into our entry block. + // Depending on how the parent function was laid out, the block that will + // correspond to the outlined entry block may not be the first block in the + // list. We can recognize it, however, as the cloned block which has no + // predecessors. Any other block wouldn't have been cloned if it didn't + // have a predecessor which was also cloned. + Function::iterator ClonedIt = std::next(Function::iterator(Entry)); + while (!pred_empty(ClonedIt)) + ++ClonedIt; + BasicBlock *ClonedEntryBB = ClonedIt; + assert(ClonedEntryBB); + Entry->getInstList().splice(Entry->end(), ClonedEntryBB->getInstList()); + ClonedEntryBB->eraseFromParent(); // Make sure we can identify the handler's personality later. addStubInvokeToHandlerIfNeeded(Handler, LPad->getPersonalityFn()); |