Skip to content

Commit 28d1cf9

Browse files
Merge pull request #78424 from aschwaighofer/outlinining_collector_fix_6.1
[6.1] IRGen: OutliningCollector's bindPolymorphicParameters needs to disambiguate between Formal and Representational metadata types
2 parents f2fa88a + 02f78ef commit 28d1cf9

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

lib/IRGen/Outlining.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,14 @@ void OutliningMetadataCollector::bindPolymorphicParameters(
246246
auto key = pair.first;
247247
assert(key.Kind.isAnyTypeMetadata());
248248
setTypeMetadataName(IGF.IGM, arg, key.Type);
249-
IGF.bindLocalTypeDataFromTypeMetadata(key.Type,
250-
IsExact,
251-
arg,
252-
MetadataState::Complete);
249+
if (key.Kind == LocalTypeDataKind::forRepresentationTypeMetadata()) {
250+
IGF.setUnscopedLocalTypeData(key, MetadataResponse::forComplete(arg));
251+
} else {
252+
IGF.bindLocalTypeDataFromTypeMetadata(key.Type,
253+
IsExact,
254+
arg,
255+
MetadataState::Complete);
256+
}
253257
}
254258
return;
255259
}

test/IRGen/outlined_copy_addr.sil

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
3+
// RUN: %target-swift-frontend -emit-ir %s -I %t | %FileCheck %s
4+
5+
import Swift
6+
import resilient_struct
7+
8+
indirect enum E<A, B> {
9+
case a(A, B)
10+
case b(B)
11+
case c(A)
12+
case d
13+
}
14+
15+
// This used to crash when generating the outlined copy function.
16+
// CHECK: s18outlined_copy_addr1EOyxq_G_S2i16resilient_struct12ResilientIntVIeg_tSgr0_lWOb
17+
18+
sil @test : $@convention(thin) <ItemA, ItemB> () -> () {
19+
bb0:
20+
%1 = alloc_stack $Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
21+
%2 = alloc_stack $Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
22+
copy_addr [take] %1 to [init] %2 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
23+
dealloc_stack %2 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
24+
dealloc_stack %1 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
25+
%t = tuple ()
26+
return %t: $()
27+
}

0 commit comments

Comments
 (0)