From 44b3f961e10d4bf5d12998622ece2805723a6cdd Mon Sep 17 00:00:00 2001 From: Joseph Tremoulet Date: Fri, 15 Jan 2016 21:16:19 +0000 Subject: [PATCH] [WinEH] Rename CatchReturnInst::getParentPad, NFC Summary: Rename to getCatchSwitchParentPad, to make it more clear which ancestor the "parent" in question is. Add a comment pointing out the key feature that the returned pad indicates which funclet contains the successor block. Reviewers: rnk, andrew.w.kaylor, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16222 llvm-svn: 257933 --- llvm/include/llvm/IR/Instructions.h | 4 +++- llvm/lib/Analysis/EHPersonalities.cpp | 2 +- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 2 +- llvm/lib/CodeGen/WinEHPrepare.cpp | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index aba48ca6fa9e..cb7eeb4994a2 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -4152,7 +4152,9 @@ public: } 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(); } diff --git a/llvm/lib/Analysis/EHPersonalities.cpp b/llvm/lib/Analysis/EHPersonalities.cpp index 01be8b38fadd..4868b66139b6 100644 --- a/llvm/lib/Analysis/EHPersonalities.cpp +++ b/llvm/lib/Analysis/EHPersonalities.cpp @@ -92,7 +92,7 @@ DenseMap llvm::colorEHFunclets(Function &F) { 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 diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index f3ddf41adaaf..4e645a0d32d5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1206,7 +1206,7 @@ void SelectionDAGBuilder::visitCatchRet(const CatchReturnInst &I) { // 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(); diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 886c5f6070c1..281fe9342926 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -787,7 +787,7 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) { 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 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) { 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!");