Skip to content

Commit fde9825

Browse files
committed
Add CastBranchInstBase::SuccessorPath for easier factoring.
Code that handles checked_cast_br can not be factored easily without coding separate paths for each successor.
1 parent 0435fef commit fde9825

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/swift/SIL/SILInstruction.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8767,10 +8767,13 @@ template <typename BaseTy> class CastBranchInstBase : public BaseTy {
87678767

87688768
TermInst::SuccessorListTy getSuccessors() { return DestBBs; }
87698769

8770-
SILBasicBlock *getSuccessBB() { return DestBBs[0]; }
8771-
const SILBasicBlock *getSuccessBB() const { return DestBBs[0]; }
8772-
SILBasicBlock *getFailureBB() { return DestBBs[1]; }
8773-
const SILBasicBlock *getFailureBB() const { return DestBBs[1]; }
8770+
// Enumerate the successor indices
8771+
enum SuccessorPath { SuccessIdx = 0, FailIdx = 1};
8772+
8773+
SILBasicBlock *getSuccessBB() { return DestBBs[SuccessIdx]; }
8774+
const SILBasicBlock *getSuccessBB() const { return DestBBs[SuccessIdx]; }
8775+
SILBasicBlock *getFailureBB() { return DestBBs[FailIdx]; }
8776+
const SILBasicBlock *getFailureBB() const { return DestBBs[FailIdx]; }
87748777

87758778
/// The number of times the True branch was executed
87768779
ProfileCounter getTrueBBCount() const { return DestBBs[0].getCount(); }

0 commit comments

Comments
 (0)