summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2015-10-16 18:08:16 +0000
committerJoseph Tremoulet <jotrem@microsoft.com>2015-10-16 18:08:16 +0000
commit53e9cbd95a66bb95a286a190054b01c4222068c6 (patch)
tree49843010c27862ddfb960ab1f7d59e840ca8bcc9 /llvm/lib/CodeGen
parent5f3fd800f7f2cad6d6519c3ec54cce1324ed1e14 (diff)
downloadbcm5719-llvm-53e9cbd95a66bb95a286a190054b01c4222068c6.tar.gz
bcm5719-llvm-53e9cbd95a66bb95a286a190054b01c4222068c6.zip
[WinEH] Fix endpad coloring/numbering
Summary: When a cleanup's cleanupendpad or cleanupret targets a catchendpad, stop trying to propagate the cleanup's parent's color to the catchendpad, since what's needed is the cleanup's grandparent's color and the catchendpad will get that color from the catchpad linkage already. We already had this exclusion for invokes, but were missing it for cleanupendpad/cleanupret. Also add a missing line that tags cleanupendpads' states in the EHPadStateMap, without with lowering invokes that target cleanupendpads which unwind to other handlers (and so don't have the -1 state) will fail. This fixes the reduced IR repro in PR25163. Reviewers: majnemer, andrew.w.kaylor, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13797 llvm-svn: 250534
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/WinEHPrepare.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp
index 56648538f98..122d2fa2ce7 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -306,6 +306,7 @@ static void calculateExplicitCXXStateNumbers(WinEHFuncInfo &FuncInfo,
BasicBlock *CleanupBlock = CEPI->getCleanupPad()->getParent();
calculateExplicitCXXStateNumbers(FuncInfo, *CleanupBlock, ParentState);
// Anything unwinding through CleanupEndPadInst is in ParentState.
+ FuncInfo.EHPadStateMap[FirstNonPHI] = ParentState;
for (const BasicBlock *PredBlock : predecessors(&BB))
if ((PredBlock = getEHPadFromPredecessor(PredBlock)))
calculateExplicitCXXStateNumbers(FuncInfo, *PredBlock, ParentState);
@@ -614,12 +615,20 @@ colorFunclets(Function &F, SmallVectorImpl<BasicBlock *> &EntryBlocks,
!isa<CleanupEndPadInst>(VisitingHead)) {
// Mark this as a funclet head as a member of itself.
FuncletBlocks[Visiting].insert(Visiting);
- // Queue exits with the parent color.
+ // Queue exits (i.e. successors of rets/endpads) with the parent color.
+ // Skip any exits that are catchendpads, since the parent color must then
+ // represent one of the catches chained to that catchendpad, but the
+ // catchendpad should get the color of the common parent of all its
+ // chained catches (i.e. the grandparent color of the current pad).
+ // We don't need to worry abou catchendpads going unvisited, since the
+ // catches chained to them must have unwind edges to them by which we will
+ // visit them.
for (User *U : VisitingHead->users()) {
if (auto *Exit = dyn_cast<TerminatorInst>(U)) {
for (BasicBlock *Succ : successors(Exit->getParent()))
- if (BlockColors[Succ].insert(Color).second)
- Worklist.push_back({Succ, Color});
+ if (!isa<CatchEndPadInst>(*Succ->getFirstNonPHI()))
+ if (BlockColors[Succ].insert(Color).second)
+ Worklist.push_back({Succ, Color});
}
}
// Handle CatchPad specially since its successors need different colors.
OpenPOWER on IntegriCloud