File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -1341,6 +1341,12 @@ bool SILInstruction::mayRequirePackMetadata() const {
13411341 if (isDeallocatingStack ())
13421342 return false ;
13431343
1344+ // Terminators that exit the function must not result in pack metadata
1345+ // materialization.
1346+ auto *ti = dyn_cast<TermInst>(this );
1347+ if (ti && ti->isFunctionExiting ())
1348+ return false ;
1349+
13441350 // Check results and operands for packs. If a pack appears, lowering the
13451351 // instruction might result in pack metadata emission.
13461352 for (auto result : getResults ()) {
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ struct S1 {}
2222struct S2 {}
2323struct S3 {}
2424
25+ struct GVT<each T> : Error {
26+ }
27+
2528struct GV<each T> {
2629 var tu: (repeat each T)
2730}
@@ -143,6 +146,16 @@ entry:
143146 return %retval : $()
144147}
145148
149+ // CHECK-SIL-LABEL: sil @return_variadic : {{.*}} {
150+ // CHECK-SIL: [[RETVAL:%[^,]+]] = struct
151+ // CHECK-SIL: return [[RETVAL]]
152+ // CHECK-SIL-LABEL: } // end sil function 'return_variadic'
153+ sil @return_variadic : $<each T>() -> GVT<repeat each T> {
154+ entry:
155+ %retval = struct $GVT<repeat each T> ()
156+ return %retval : $GVT<repeat each T>
157+ }
158+
146159// =============================================================================
147160// FINISH: Instructions: Apply }}
148161// =============================================================================
Original file line number Diff line number Diff line change 1+ // RUN: %target-sil-opt -enable-sil-verify-all %s -pack-metadata-marker-inserter -enable-pack-metadata-stack-promotion=true | %FileCheck %s --check-prefixes CHECK-SIL
2+
3+ // REQUIRES: asserts
4+
5+ sil_stage lowered
6+
7+ import Builtin
8+
9+ protocol Error {}
10+
11+ struct GVT<each T> {
12+ }
13+
14+ // CHECK-SIL-LABEL: sil @throw_variadic : {{.*}} {
15+ // CHECK-SIL: [[ERROR:%[^,]+]] = struct
16+ // CHECK-SIL: throw [[ERROR]]
17+ // CHECK-SIL-LABEL: } // end sil function 'throw_variadic'
18+ sil @throw_variadic : $<each T>() -> ((), @error GVT<repeat each T>) {
19+ entry:
20+ %retval = struct $GVT<repeat each T> ()
21+ throw %retval : $GVT<repeat each T>
22+ }
23+
You can’t perform that action at this time.
0 commit comments