Skip to content

Commit b15fb39

Browse files
authored
Merge pull request #15284 from gottesmm/pr-e8e43bea941a0a620f95f83de9b489648d2227ec
2 parents b2bc9e4 + 5f1e1c6 commit b15fb39

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ class PatternMatchEmission {
486486
const FailureHandler &failure);
487487
void emitEnumElementDispatchWithOwnership(
488488
ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
489-
const SpecializationHandler &handleSpec, const FailureHandler &failure);
489+
const SpecializationHandler &handleSpec, const FailureHandler &failure,
490+
ProfileCounter defaultCaseCount);
490491
void emitEnumElementDispatch(ArrayRef<RowToSpecialize> rows,
491492
ConsumableManagedValue src,
492493
const SpecializationHandler &handleSpec,
@@ -1795,8 +1796,8 @@ static void generateEnumCaseBlocks(
17951796
/// OptionalSomePattern.
17961797
void PatternMatchEmission::emitEnumElementDispatchWithOwnership(
17971798
ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
1798-
const SpecializationHandler &handleCase,
1799-
const FailureHandler &outerFailure) {
1799+
const SpecializationHandler &handleCase, const FailureHandler &outerFailure,
1800+
ProfileCounter defaultCastCount) {
18001801
assert(src.getFinalConsumption() != CastConsumptionKind::TakeOnSuccess &&
18011802
"SIL ownership does not support TakeOnSuccess");
18021803

@@ -1821,7 +1822,9 @@ void PatternMatchEmission::emitEnumElementDispatchWithOwnership(
18211822
SILValue srcValue = src.getFinalManagedValue().copy(SGF, loc).forward(SGF);
18221823
// FIXME: Pass caseCounts in here as well, as it is in
18231824
// emitEnumElementDispatch.
1824-
SGF.B.createSwitchEnum(loc, srcValue, defaultBB, caseBBs);
1825+
ArrayRef<ProfileCounter> caseCountsArrayRef = caseCounts;
1826+
SGF.B.createSwitchEnum(loc, srcValue, defaultBB, caseBBs, caseCountsArrayRef,
1827+
defaultCastCount);
18251828

18261829
// Okay, now emit all the cases.
18271830
for (unsigned i = 0, e = caseInfos.size(); i != e; ++i) {
@@ -1940,7 +1943,7 @@ void PatternMatchEmission::emitEnumElementDispatch(
19401943
// use the dispatch code path.
19411944
if (SGF.getOptions().EnableSILOwnership && src.getType().isObject()) {
19421945
return emitEnumElementDispatchWithOwnership(rows, src, handleCase,
1943-
outerFailure);
1946+
outerFailure, defaultCaseCount);
19441947
}
19451948

19461949
CanType sourceType = rows[0].Pattern->getType()->getCanonicalType();

0 commit comments

Comments
 (0)