Index: include/llvm/IR/Instructions.h =================================================================== --- include/llvm/IR/Instructions.h +++ include/llvm/IR/Instructions.h @@ -4152,7 +4152,9 @@ } unsigned getNumSuccessors() const { return 1; } - Value *getParentPad() const { + /// Get the parentPad of this catchret's catchpad's catchswitch. + /// The successor block is implicitly a member of this funclet. + Value *getCatchSwitchParentPad() const { return getCatchPad()->getCatchSwitch()->getParentPad(); } Index: lib/Analysis/EHPersonalities.cpp =================================================================== --- lib/Analysis/EHPersonalities.cpp +++ lib/Analysis/EHPersonalities.cpp @@ -92,7 +92,7 @@ BasicBlock *SuccColor = Color; TerminatorInst *Terminator = Visiting->getTerminator(); if (auto *CatchRet = dyn_cast(Terminator)) { - Value *ParentPad = CatchRet->getParentPad(); + Value *ParentPad = CatchRet->getCatchSwitchParentPad(); if (isa(ParentPad)) SuccColor = EntryBlock; else Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1206,7 +1206,7 @@ // This will be used by the FuncletLayout pass to determine how to order the // BB's. // A 'catchret' returns to the outer scope's color. - Value *ParentPad = I.getParentPad(); + Value *ParentPad = I.getCatchSwitchParentPad(); const BasicBlock *SuccessorColor; if (isa(ParentPad)) SuccessorColor = &FuncInfo.Fn->getEntryBlock(); Index: lib/CodeGen/WinEHPrepare.cpp =================================================================== --- lib/CodeGen/WinEHPrepare.cpp +++ lib/CodeGen/WinEHPrepare.cpp @@ -787,7 +787,7 @@ FixupCatchrets.clear(); for (BasicBlock *Pred : predecessors(OldBlock)) if (auto *CatchRet = dyn_cast(Pred->getTerminator())) - if (CatchRet->getParentPad() == FuncletToken) + if (CatchRet->getCatchSwitchParentPad() == FuncletToken) FixupCatchrets.push_back(CatchRet); for (CatchReturnInst *CatchRet : FixupCatchrets) @@ -802,7 +802,7 @@ bool EdgeTargetsFunclet; if (auto *CRI = dyn_cast(IncomingBlock->getTerminator())) { - EdgeTargetsFunclet = (CRI->getParentPad() == FuncletToken); + EdgeTargetsFunclet = (CRI->getCatchSwitchParentPad() == FuncletToken); } else { ColorVector &IncomingColors = BlockColors[IncomingBlock]; assert(!IncomingColors.empty() && "Block not colored!");