Skip to content

Commit e6a984d

Browse files
committed
SILGen: Move some code around in pattern emission
1 parent aa43c26 commit e6a984d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,10 +2580,6 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
25802580
emitIgnoredExpr(S->getSubjectExpr());
25812581
return failure(SILLocation(S));
25822582
}
2583-
2584-
SILBasicBlock *contBB = createBasicBlock();
2585-
emitProfilerIncrement(S);
2586-
JumpDest contDest(contBB, Cleanups.getCleanupsDepth(), CleanupLocation(S));
25872583

25882584
bool diagnosedError = false;
25892585

@@ -2662,19 +2658,6 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
26622658
};
26632659

26642660
PatternMatchEmission emission(*this, S, completionHandler);
2665-
2666-
Scope switchScope(Cleanups, CleanupLocation(S));
2667-
2668-
// Enter a break/continue scope. If we wanted a continue
2669-
// destination, it would probably be out here.
2670-
BreakContinueDestStack.push_back({S, contDest, JumpDest(S)});
2671-
2672-
PatternMatchContext switchContext = { emission };
2673-
SwitchStack.push_back(&switchContext);
2674-
2675-
// Emit the subject value. Dispatching will consume it.
2676-
ManagedValue subjectMV = emitRValueAsSingleValue(S->getSubjectExpr());
2677-
auto subject = ConsumableManagedValue::forOwned(subjectMV);
26782661

26792662
// Add a row for each label of each case.
26802663
//
@@ -2700,6 +2683,23 @@ void SILGenFunction::emitSwitchStmt(SwitchStmt *S) {
27002683
hasFallthrough = containsFallthrough(caseBlock->getBody());
27012684
}
27022685

2686+
SILBasicBlock *contBB = createBasicBlock();
2687+
emitProfilerIncrement(S);
2688+
JumpDest contDest(contBB, Cleanups.getCleanupsDepth(), CleanupLocation(S));
2689+
2690+
Scope switchScope(Cleanups, CleanupLocation(S));
2691+
2692+
// Enter a break/continue scope. If we wanted a continue
2693+
// destination, it would probably be out here.
2694+
BreakContinueDestStack.push_back({S, contDest, JumpDest(S)});
2695+
2696+
PatternMatchContext switchContext = { emission };
2697+
SwitchStack.push_back(&switchContext);
2698+
2699+
// Emit the subject value. Dispatching will consume it.
2700+
ManagedValue subjectMV = emitRValueAsSingleValue(S->getSubjectExpr());
2701+
auto subject = ConsumableManagedValue::forOwned(subjectMV);
2702+
27032703
// Set up an initial clause matrix.
27042704
ClauseMatrix clauses(clauseRows);
27052705

0 commit comments

Comments
 (0)