Skip to content

Commit aa118a7

Browse files
authored
Merge pull request #19840 from gottesmm/pr-b1a0a45c5f7ddde8879ac6fcf10003e0805603f9
[silgenpattern] Change all loadable types to always go through the ownership preserving tuple code.
2 parents 5aae774 + 359eda5 commit aa118a7

File tree

6 files changed

+93
-89
lines changed

6 files changed

+93
-89
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ class PatternMatchEmission {
465465
void emitSpecializedDispatch(ClauseMatrix &matrix, ArgArray args,
466466
unsigned &lastRow, unsigned column,
467467
const FailureHandler &failure);
468-
void emitTupleDispatchWithOwnership(ArrayRef<RowToSpecialize> rows,
469-
ConsumableManagedValue src,
470-
const SpecializationHandler &handleSpec,
471-
const FailureHandler &failure);
468+
void emitTupleObjectDispatch(ArrayRef<RowToSpecialize> rows,
469+
ConsumableManagedValue src,
470+
const SpecializationHandler &handleSpec,
471+
const FailureHandler &failure);
472472
void emitTupleDispatch(ArrayRef<RowToSpecialize> rows,
473473
ConsumableManagedValue src,
474474
const SpecializationHandler &handleSpec,
@@ -738,15 +738,19 @@ forwardIntoSubtree(SILGenFunction &SGF, SILLocation loc,
738738
ManagedValue outerMV = outerCMV.getFinalManagedValue();
739739
if (!outerMV.hasCleanup()) return outerCMV;
740740

741-
assert(outerCMV.getFinalConsumption() != CastConsumptionKind::CopyOnSuccess
742-
&& "copy-on-success value with cleanup?");
741+
auto consumptionKind = outerCMV.getFinalConsumption();
742+
(void)consumptionKind;
743+
assert((consumptionKind == CastConsumptionKind::TakeAlways ||
744+
consumptionKind == CastConsumptionKind::TakeOnSuccess) &&
745+
"non-+1 consumption with a cleanup?");
743746
scope.pushCleanupState(outerMV.getCleanup(),
744747
CleanupState::PersistentlyActive);
745748

746-
// If SILOwnership is enabled, we always forward down values as borrows that
747-
// are copied on success.
748-
if (SGF.F.getModule().getOptions().EnableSILOwnership) {
749-
return {outerMV.borrow(SGF, loc), CastConsumptionKind::CopyOnSuccess};
749+
// If SILOwnership is enabled and we have an object, borrow instead of take on
750+
// success.
751+
if (SGF.F.getModule().getOptions().EnableSILOwnership &&
752+
outerMV.getType().isObject()) {
753+
return {outerMV.borrow(SGF, loc), CastConsumptionKind::BorrowAlways};
750754
}
751755

752756
// Success means that we won't end up in the other branch,
@@ -766,9 +770,6 @@ static void forwardIntoIrrefutableSubtree(SILGenFunction &SGF,
766770

767771
assert(outerCMV.getFinalConsumption() != CastConsumptionKind::CopyOnSuccess
768772
&& "copy-on-success value with cleanup?");
769-
assert((!SGF.F.getModule().getOptions().EnableSILOwnership ||
770-
outerCMV.getFinalConsumption() == CastConsumptionKind::TakeAlways) &&
771-
"When semantic sil is enabled, we should never see TakeOnSuccess");
772773
scope.pushCleanupState(outerMV.getCleanup(),
773774
CleanupState::PersistentlyActive);
774775

@@ -899,17 +900,9 @@ class ArgUnforwarder {
899900

900901
static bool requiresUnforwarding(SILGenFunction &SGF,
901902
ConsumableManagedValue operand) {
902-
if (SGF.F.getModule().getOptions().EnableSILOwnership) {
903-
assert(operand.getFinalConsumption() !=
904-
CastConsumptionKind::TakeOnSuccess &&
905-
"When compiling with sil ownership take on success is disabled");
906-
// No unforwarding is needed, we always borrow/copy.
907-
return false;
908-
}
909-
910-
return (operand.hasCleanup() &&
911-
operand.getFinalConsumption()
912-
== CastConsumptionKind::TakeOnSuccess);
903+
return operand.hasCleanup() &&
904+
operand.getFinalConsumption()
905+
== CastConsumptionKind::TakeOnSuccess;
913906
}
914907

915908
/// Given that an aggregate was divided into a set of borrowed
@@ -1356,9 +1349,6 @@ getManagedSubobject(SILGenFunction &SGF, SILValue value,
13561349
return {ManagedValue::forUnmanaged(value), consumption};
13571350
case CastConsumptionKind::TakeAlways:
13581351
case CastConsumptionKind::TakeOnSuccess:
1359-
assert((!SGF.F.getModule().getOptions().EnableSILOwnership ||
1360-
consumption != CastConsumptionKind::TakeOnSuccess) &&
1361-
"TakeOnSuccess should never be used when sil ownership is enabled");
13621352
return {SGF.emitManagedRValueWithCleanup(value, valueTL), consumption};
13631353
}
13641354
}
@@ -1381,7 +1371,7 @@ emitReabstractedSubobject(SILGenFunction &SGF, SILLocation loc,
13811371
SGF.emitOrigToSubstValue(loc, mv, abstraction, substFormalType));
13821372
}
13831373

1384-
void PatternMatchEmission::emitTupleDispatchWithOwnership(
1374+
void PatternMatchEmission::emitTupleObjectDispatch(
13851375
ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
13861376
const SpecializationHandler &handleCase,
13871377
const FailureHandler &outerFailure) {
@@ -1409,8 +1399,7 @@ void PatternMatchEmission::emitTupleDispatchWithOwnership(
14091399
destructured.push_back({v, src.getFinalConsumption()});
14101400
});
14111401

1412-
// Break down the values.
1413-
// Recurse.
1402+
// Since we did all of our work at +0, we just send down the outer failure.
14141403
handleCase(destructured, specializedRows, outerFailure);
14151404
}
14161405

@@ -1421,13 +1410,45 @@ void PatternMatchEmission::
14211410
emitTupleDispatch(ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
14221411
const SpecializationHandler &handleCase,
14231412
const FailureHandler &outerFailure) {
1424-
if (SGF.getOptions().EnableSILOwnership && src.getType().isObject()) {
1425-
return emitTupleDispatchWithOwnership(rows, src, handleCase, outerFailure);
1426-
}
14271413
auto firstPat = rows[0].Pattern;
1428-
auto sourceType = cast<TupleType>(firstPat->getType()->getCanonicalType());
14291414
SILLocation loc = firstPat;
14301415

1416+
// If our source is an address that is loadable, perform a load_borrow.
1417+
if (src.getType().isAddress() && src.getType().isLoadable(SGF.getModule())) {
1418+
src = {SGF.B.createLoadBorrow(loc, src.getFinalManagedValue()),
1419+
CastConsumptionKind::BorrowAlways};
1420+
}
1421+
1422+
// Then if we have an object...
1423+
if (src.getType().isObject()) {
1424+
// Make sure that if we ahve a copy_on_success, non-trivial value that we do
1425+
// not have a value with @owned ownership.
1426+
assert((!src.getType().isTrivial(SGF.getModule()) ||
1427+
src.getFinalConsumption() != CastConsumptionKind::CopyOnSuccess ||
1428+
src.getOwnershipKind() != ValueOwnershipKind::Owned) &&
1429+
"@owned value without cleanup + copy_on_success");
1430+
1431+
// If we have are asked to perform TakeOnSuccess, borrow the value instead.
1432+
//
1433+
// The reason why do this for TakeOnSuccess is that we want to not have to
1434+
// deal with unforwarding of aggregate tuples in failing cases since that
1435+
// causes ownership invariants to be violated since we already forwarded the
1436+
// aggregate to create cleanups on its elements.
1437+
//
1438+
// In contrast, we do still want to allow for TakeAlways variants to not
1439+
// need to borrow, so we do not borrow if we take always.
1440+
if (!src.getType().isTrivial(SGF.getModule()) &&
1441+
src.getFinalConsumption() == CastConsumptionKind::TakeOnSuccess) {
1442+
src = {src.getFinalManagedValue().borrow(SGF, loc),
1443+
CastConsumptionKind::BorrowAlways};
1444+
}
1445+
1446+
// Then perform a forward or reborrow destructure on the object.
1447+
return emitTupleObjectDispatch(rows, src, handleCase, outerFailure);
1448+
}
1449+
1450+
auto sourceType = cast<TupleType>(firstPat->getType()->getCanonicalType());
1451+
14311452
SILValue v = src.getFinalManagedValue().forward(SGF);
14321453
SmallVector<ConsumableManagedValue, 4> destructured;
14331454

@@ -1882,8 +1903,6 @@ void PatternMatchEmission::emitEnumElementDispatch(
18821903
break;
18831904

18841905
case CastConsumptionKind::TakeOnSuccess:
1885-
assert(!SGF.F.getModule().getOptions().EnableSILOwnership &&
1886-
"TakeOnSuccess is not supported when compiling with ownership");
18871906
// If any of the specialization cases is refutable, we must copy.
18881907
if (!blocks.hasAnyRefutableCase())
18891908
break;
@@ -1966,8 +1985,6 @@ void PatternMatchEmission::emitEnumElementDispatch(
19661985
auto eltConsumption = src.getFinalConsumption();
19671986
if (caseInfo.Irrefutable &&
19681987
eltConsumption == CastConsumptionKind::TakeOnSuccess) {
1969-
assert(!SGF.F.getModule().getOptions().EnableSILOwnership &&
1970-
"TakeOnSuccess is not supported when compiling with ownership");
19711988
eltConsumption = CastConsumptionKind::TakeAlways;
19721989
}
19731990

@@ -2760,8 +2777,9 @@ void SILGenFunction::emitCatchDispatch(DoCatchStmt *S, ManagedValue exn,
27602777
// Set up an initial clause matrix.
27612778
ClauseMatrix clauseMatrix(clauseRows);
27622779
ConsumableManagedValue subject;
2763-
if (F.getModule().getOptions().EnableSILOwnership) {
2764-
subject = {exn.borrow(*this, S), CastConsumptionKind::CopyOnSuccess};
2780+
if (F.getModule().getOptions().EnableSILOwnership &&
2781+
exn.getType().isObject()) {
2782+
subject = {exn.borrow(*this, S), CastConsumptionKind::BorrowAlways};
27652783
} else {
27662784
subject = {exn, CastConsumptionKind::TakeOnSuccess};
27672785
}

test/SILGen/indirect_enum.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ func switchTreeA<T>(_ x: TreeA<T>) {
176176
// CHECK: [[BRANCH_CASE]]([[NODE_BOX:%.*]] : @owned $<τ_0_0> { var (left: TreeA<τ_0_0>, right: TreeA<τ_0_0>) } <T>):
177177
// CHECK: [[TUPLE_ADDR:%.*]] = project_box [[NODE_BOX]]
178178
// CHECK: [[TUPLE:%.*]] = load_borrow [[TUPLE_ADDR]]
179-
// CHECK: [[LEFT:%.*]] = tuple_extract [[TUPLE]] {{.*}}, 0
180-
// CHECK: [[RIGHT:%.*]] = tuple_extract [[TUPLE]] {{.*}}, 1
179+
// CHECK: ([[LEFT:%.*]], [[RIGHT:%.*]]) = destructure_tuple [[TUPLE]]
181180
// CHECK: switch_enum [[LEFT]] : $TreeA<T>,
182181
// CHECK: case #TreeA.Leaf!enumelt.1: [[LEAF_CASE_LEFT:bb[0-9]+]],
183182
// CHECK: default [[FAIL_LEFT:bb[0-9]+]]

test/SILGen/switch.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,7 @@ func test_union_1(u: MaybePair) {
705705

706706
// CHECK: [[IS_BOTH]]([[TUP:%.*]] : @owned $(Int, String)):
707707
case .Both:
708-
// CHECK: tuple_extract [[TUP]] : $(Int, String), 0
709-
// CHECK: [[TUP_STR:%.*]] = tuple_extract [[TUP]] : $(Int, String), 1
708+
// CHECK: ({{%.*}}, [[TUP_STR:%.*]]) = destructure_tuple [[TUP]]
710709
// CHECK: destroy_value [[TUP_STR]] : $String
711710
// CHECK: function_ref @$s6switch1dyyF
712711
// CHECK: br [[CONT]]
@@ -915,9 +914,7 @@ enum Foo { case A, B }
915914
// CHECK-LABEL: sil hidden @$s6switch05test_A11_two_unions1x1yyAA3FooO_AFtF
916915
func test_switch_two_unions(x: Foo, y: Foo) {
917916
// CHECK: [[T0:%.*]] = tuple (%0 : $Foo, %1 : $Foo)
918-
// CHECK: [[X:%.*]] = tuple_extract [[T0]] : $(Foo, Foo), 0
919-
// CHECK: [[Y:%.*]] = tuple_extract [[T0]] : $(Foo, Foo), 1
920-
917+
// CHECK: ([[X:%.*]], [[Y:%.*]]) = destructure_tuple [[T0]]
921918
// CHECK: switch_enum [[Y]] : $Foo, case #Foo.A!enumelt: [[IS_CASE1:bb[0-9]+]], default [[IS_NOT_CASE1:bb[0-9]+]]
922919

923920
switch (x, y) {
@@ -980,8 +977,7 @@ func rdar14835992<T, U>(t: Rdar14835992, tt: T, uu: U) {
980977
enum ABC { case A, B, C }
981978

982979
// CHECK-LABEL: sil hidden @$s6switch18testTupleWildcardsyyAA3ABCO_ADtF
983-
// CHECK: [[X:%.*]] = tuple_extract {{%.*}} : $(ABC, ABC), 0
984-
// CHECK: [[Y:%.*]] = tuple_extract {{%.*}} : $(ABC, ABC), 1
980+
// CHECK: ([[X:%.*]], [[Y:%.*]]) = destructure_tuple {{%.*}} : $(ABC, ABC)
985981
// CHECK: switch_enum [[X]] : $ABC, case #ABC.A!enumelt: [[X_A:bb[0-9]+]], default [[X_NOT_A:bb[0-9]+]]
986982
// CHECK: [[X_A]]:
987983
// CHECK: function_ref @$s6switch1ayyF
@@ -1022,7 +1018,7 @@ func testLabeledScalarPayload(_ lsp: LabeledScalarPayload) -> Any {
10221018
// CHECK: switch_enum {{%.*}}, case #LabeledScalarPayload.Payload!enumelt.1: bb1
10231019
switch lsp {
10241020
// CHECK: bb1([[TUPLE:%.*]] : @trivial $(name: Int)):
1025-
// CHECK: [[X:%.*]] = tuple_extract [[TUPLE]]
1021+
// CHECK: [[X:%.*]] = destructure_tuple [[TUPLE]]
10261022
// CHECK: [[ANY_X_ADDR:%.*]] = init_existential_addr {{%.*}}, $Int
10271023
// CHECK: store [[X]] to [trivial] [[ANY_X_ADDR]]
10281024
case let .Payload(x):

test/SILGen/switch_isa.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ func guardFn(_ l: D, _ r: D) -> Bool { return true }
5555
// CHECK: [[ARG0_COPY:%.*]] = copy_value [[ARG0]]
5656
// CHECK: [[ARG1_COPY:%.*]] = copy_value [[ARG1]]
5757
// CHECK: [[TUP:%.*]] = tuple ([[ARG0_COPY:%.*]] : $B, [[ARG1_COPY:%.*]] : $B)
58-
// TODO: This should be destructures not tuple extracts.
59-
// CHECK: [[TUP_1:%.*]] = tuple_extract [[TUP]] : $(B, B), 0
60-
// CHECK: [[TUP_2:%.*]] = tuple_extract [[TUP]] : $(B, B), 1
58+
// CHECK: [[BORROWED_TUP:%.*]] = begin_borrow [[TUP]]
59+
// CHECK: ([[TUP_1:%.*]], [[TUP_2:%.*]]) = destructure_tuple [[BORROWED_TUP]]
6160
// CHECK: checked_cast_br [[TUP_1]] : $B to $D, [[R_CAST_YES:bb[0-9]+]], [[R_CAST_NO:bb[0-9]+]]
6261
//
6362
// CHECK: [[R_CAST_YES]]([[R:%.*]] : @guaranteed $D):
@@ -74,8 +73,8 @@ func guardFn(_ l: D, _ r: D) -> Bool { return true }
7473
// CHECK-NEXT: destroy_value [[R2]]
7574
// CHECK-NEXT: end_borrow [[L]]
7675
// CHECK-NEXT: end_borrow [[R]]
77-
// CHECK-NEXT: destroy_value [[TUP_2]]
78-
// CHECK-NEXT: destroy_value [[TUP_1]]
76+
// CHECK-NEXT: end_borrow [[BORROWED_TUP]]
77+
// CHECK-NEXT: destroy_value [[TUP]]
7978
// CHECK-NEXT: br [[EXIT:bb[0-9]+]]
8079
//
8180
// CHECK: [[GUARD_NO]]:
@@ -84,12 +83,14 @@ func guardFn(_ l: D, _ r: D) -> Bool { return true }
8483
// TODO: Infer end_borrow from the input begin_borrow. This should be eliminated.
8584
// CHECK-NEXT: end_borrow [[L]]
8685
// CHECK-NEXT: end_borrow [[R]]
86+
// CHECK-NEXT: end_borrow [[BORROWED_TUP]]
8787
// CHECK-NEXT: br [[CONT:bb[0-9]+]]
8888
//
8989
// CHECK: [[L_CAST_NO]]([[LFAIL:%.*]] : @guaranteed $B):
9090
// CHECK-NEXT: end_borrow [[LFAIL]]
9191
// CHECK-NEXT: destroy_value [[R2]]
9292
// CHECK-NEXT: end_borrow [[R]]
93+
// CHECK-NEXT: end_borrow [[BORROWED_TUP]]
9394
// CHECK-NEXT: br [[CONT]]
9495
//
9596
// CHECK: [[CONT]]:

test/SILGen/switch_ownership.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func test_switch_two_trivial_unions(x: Foo, y: Foo) {
6060
// CHECK: unreachable
6161
}
6262
}
63+
// CHECK: } // end sil function '$s6switch05test_A19_two_trivial_unions1x1yyAA3FooO_AFtF'
6364

6465
// CHECK-LABEL: sil hidden @$s6switch05test_A22_two_nontrivial_unions1x1yyAA13NonTrivialFooO_AFtF : $@convention(thin) (@guaranteed NonTrivialFoo, @guaranteed NonTrivialFoo) -> () {
6566
func test_switch_two_nontrivial_unions(x: NonTrivialFoo, y: NonTrivialFoo) {
@@ -98,3 +99,4 @@ func test_switch_two_nontrivial_unions(x: NonTrivialFoo, y: NonTrivialFoo) {
9899
// CHECK: unreachable
99100
}
100101
}
102+
// CHECK: } // end sil function '$s6switch05test_A22_two_nontrivial_unions1x1yyAA13NonTrivialFooO_AFtF'

test/SILGen/switch_var.swift

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -618,20 +618,16 @@ func test_multiple_patterns3() {
618618
switch f {
619619
// CHECK: switch_enum {{%.*}} : $Foo, case #Foo.A!enumelt.1: [[A:bb[0-9]+]], case #Foo.B!enumelt.1: [[B:bb[0-9]+]], case #Foo.C!enumelt.1: [[C:bb[0-9]+]]
620620
case .A(let x, let n), .B(let n, let x), .C(_, let x, let n):
621-
// CHECK: [[A]]({{%.*}} : @trivial $(Int, Double)):
622-
// CHECK: [[A_X:%.*]] = tuple_extract
623-
// CHECK: [[A_N:%.*]] = tuple_extract
621+
// CHECK: [[A]]([[A_TUP:%.*]] : @trivial $(Int, Double)):
622+
// CHECK: ([[A_X:%.*]], [[A_N:%.*]]) = destructure_tuple [[A_TUP]]
624623
// CHECK: br [[CASE_BODY:bb[0-9]+]]([[A_X]] : $Int, [[A_N]] : $Double)
625624

626-
// CHECK: [[B]]({{%.*}} : @trivial $(Double, Int)):
627-
// CHECK: [[B_N:%.*]] = tuple_extract
628-
// CHECK: [[B_X:%.*]] = tuple_extract
625+
// CHECK: [[B]]([[B_TUP:%.*]] : @trivial $(Double, Int)):
626+
// CHECK: ([[B_N:%.*]], [[B_X:%.*]]) = destructure_tuple [[B_TUP]]
629627
// CHECK: br [[CASE_BODY]]([[B_X]] : $Int, [[B_N]] : $Double)
630628

631-
// CHECK: [[C]]({{%.*}} : @trivial $(Int, Int, Double)):
632-
// CHECK: [[C__:%.*]] = tuple_extract
633-
// CHECK: [[C_X:%.*]] = tuple_extract
634-
// CHECK: [[C_N:%.*]] = tuple_extract
629+
// CHECK: [[C]]([[C_TUP:%.*]] : @trivial $(Int, Int, Double)):
630+
// CHECK: ([[C__:%.*]], [[C_X:%.*]], [[C_N:%.*]]) = destructure_tuple [[C_TUP]]
635631
// CHECK: br [[CASE_BODY]]([[C_X]] : $Int, [[C_N]] : $Double)
636632

637633
// CHECK: [[CASE_BODY]]([[BODY_X:%.*]] : @trivial $Int, [[BODY_N:%.*]] : @trivial $Double):
@@ -652,27 +648,23 @@ func test_multiple_patterns4() {
652648
switch b {
653649
// CHECK: switch_enum {{%.*}} : $Bar, case #Bar.Y!enumelt.1: [[Y:bb[0-9]+]], case #Bar.Z!enumelt.1: [[Z:bb[0-9]+]]
654650
case .Y(.A(let x, _), _), .Y(.B(_, let x), _), .Y(.C, let x), .Z(let x, _):
655-
// CHECK: [[Y]]({{%.*}} : @trivial $(Foo, Int)):
656-
// CHECK: [[Y_F:%.*]] = tuple_extract
657-
// CHECK: [[Y_X:%.*]] = tuple_extract
651+
// CHECK: [[Y]]([[Y_TUP:%.*]] : @trivial $(Foo, Int)):
652+
// CHECK: ([[Y_F:%.*]], [[Y_X:%.*]]) = destructure_tuple [[Y_TUP]]
658653
// CHECK: switch_enum [[Y_F]] : $Foo, case #Foo.A!enumelt.1: [[A:bb[0-9]+]], case #Foo.B!enumelt.1: [[B:bb[0-9]+]], case #Foo.C!enumelt.1: [[C:bb[0-9]+]]
659654

660-
// CHECK: [[A]]({{%.*}} : @trivial $(Int, Double)):
661-
// CHECK: [[A_X:%.*]] = tuple_extract
662-
// CHECK: [[A_N:%.*]] = tuple_extract
655+
// CHECK: [[A]]([[A_TUP:%.*]] : @trivial $(Int, Double)):
656+
// CHECK: ([[A_X:%.*]], [[A_N:%.*]]) = destructure_tuple [[A_TUP]]
663657
// CHECK: br [[CASE_BODY:bb[0-9]+]]([[A_X]] : $Int)
664658

665-
// CHECK: [[B]]({{%.*}} : @trivial $(Double, Int)):
666-
// CHECK: [[B_N:%.*]] = tuple_extract
667-
// CHECK: [[B_X:%.*]] = tuple_extract
659+
// CHECK: [[B]]([[B_TUP:%.*]] : @trivial $(Double, Int)):
660+
// CHECK: ([[B_N:%.*]], [[B_X:%.*]]) = destructure_tuple [[B_TUP]]
668661
// CHECK: br [[CASE_BODY]]([[B_X]] : $Int)
669662

670663
// CHECK: [[C]]({{%.*}} : @trivial $(Int, Int, Double)):
671664
// CHECK: br [[CASE_BODY]]([[Y_X]] : $Int)
672665

673-
// CHECK: [[Z]]({{%.*}} : @trivial $(Int, Foo)):
674-
// CHECK: [[Z_X:%.*]] = tuple_extract
675-
// CHECK: [[Z_F:%.*]] = tuple_extract
666+
// CHECK: [[Z]]([[Z_TUP:%.*]] : @trivial $(Int, Foo)):
667+
// CHECK: ([[Z_X:%.*]], [[Z_F:%.*]]) = destructure_tuple [[Z_TUP]]
676668
// CHECK: br [[CASE_BODY]]([[Z_X]] : $Int)
677669

678670
// CHECK: [[CASE_BODY]]([[BODY_X:%.*]] : @trivial $Int):
@@ -690,27 +682,23 @@ func test_multiple_patterns5() {
690682
switch b {
691683
// CHECK: switch_enum {{%.*}} : $Bar, case #Bar.Y!enumelt.1: [[Y:bb[0-9]+]], case #Bar.Z!enumelt.1: [[Z:bb[0-9]+]]
692684
case .Y(.A(var x, _), _), .Y(.B(_, var x), _), .Y(.C, var x), .Z(var x, _):
693-
// CHECK: [[Y]]({{%.*}} : @trivial $(Foo, Int)):
694-
// CHECK: [[Y_F:%.*]] = tuple_extract
695-
// CHECK: [[Y_X:%.*]] = tuple_extract
685+
// CHECK: [[Y]]([[Y_TUP:%.*]] : @trivial $(Foo, Int)):
686+
// CHECK: ([[Y_F:%.*]], [[Y_X:%.*]]) = destructure_tuple [[Y_TUP]]
696687
// CHECK: switch_enum [[Y_F]] : $Foo, case #Foo.A!enumelt.1: [[A:bb[0-9]+]], case #Foo.B!enumelt.1: [[B:bb[0-9]+]], case #Foo.C!enumelt.1: [[C:bb[0-9]+]]
697688

698-
// CHECK: [[A]]({{%.*}} : @trivial $(Int, Double)):
699-
// CHECK: [[A_X:%.*]] = tuple_extract
700-
// CHECK: [[A_N:%.*]] = tuple_extract
689+
// CHECK: [[A]]([[A_TUP:%.*]] : @trivial $(Int, Double)):
690+
// CHECK: ([[A_X:%.*]], [[A_N:%.*]]) = destructure_tuple [[A_TUP]]
701691
// CHECK: br [[CASE_BODY:bb[0-9]+]]([[A_X]] : $Int)
702692

703-
// CHECK: [[B]]({{%.*}} : @trivial $(Double, Int)):
704-
// CHECK: [[B_N:%.*]] = tuple_extract
705-
// CHECK: [[B_X:%.*]] = tuple_extract
693+
// CHECK: [[B]]([[B_TUP:%.*]] : @trivial $(Double, Int)):
694+
// CHECK: ([[B_N:%.*]], [[B_X:%.*]]) = destructure_tuple [[B_TUP]]
706695
// CHECK: br [[CASE_BODY]]([[B_X]] : $Int)
707696

708697
// CHECK: [[C]]({{%.*}} : @trivial $(Int, Int, Double)):
709698
// CHECK: br [[CASE_BODY]]([[Y_X]] : $Int)
710699

711-
// CHECK: [[Z]]({{%.*}} : @trivial $(Int, Foo)):
712-
// CHECK: [[Z_X:%.*]] = tuple_extract
713-
// CHECK: [[Z_F:%.*]] = tuple_extract
700+
// CHECK: [[Z]]([[Z_TUP:%.*]] : @trivial $(Int, Foo)):
701+
// CHECK: ([[Z_X:%.*]], [[Z_F:%.*]]) = destructure_tuple [[Z_TUP]]
714702
// CHECK: br [[CASE_BODY]]([[Z_X]] : $Int)
715703

716704
// CHECK: [[CASE_BODY]]([[BODY_X:%.*]] : @trivial $Int):

0 commit comments

Comments
 (0)