Skip to content

[6.1] IRGen: OutliningCollector's bindPolymorphicParameters needs to disambiguate between Formal and Representational metadata types #78424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/IRGen/Outlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ void OutliningMetadataCollector::bindPolymorphicParameters(
auto key = pair.first;
assert(key.Kind.isAnyTypeMetadata());
setTypeMetadataName(IGF.IGM, arg, key.Type);
IGF.bindLocalTypeDataFromTypeMetadata(key.Type,
IsExact,
arg,
MetadataState::Complete);
if (key.Kind == LocalTypeDataKind::forRepresentationTypeMetadata()) {
IGF.setUnscopedLocalTypeData(key, MetadataResponse::forComplete(arg));
} else {
IGF.bindLocalTypeDataFromTypeMetadata(key.Type,
IsExact,
arg,
MetadataState::Complete);
}
}
return;
}
Expand Down
27 changes: 27 additions & 0 deletions test/IRGen/outlined_copy_addr.sil
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %empty-directory(%t)
// 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
// RUN: %target-swift-frontend -emit-ir %s -I %t | %FileCheck %s

import Swift
import resilient_struct

indirect enum E<A, B> {
case a(A, B)
case b(B)
case c(A)
case d
}

// This used to crash when generating the outlined copy function.
// CHECK: s18outlined_copy_addr1EOyxq_G_S2i16resilient_struct12ResilientIntVIeg_tSgr0_lWOb

sil @test : $@convention(thin) <ItemA, ItemB> () -> () {
bb0:
%1 = alloc_stack $Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
%2 = alloc_stack $Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
copy_addr [take] %1 to [init] %2 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
dealloc_stack %2 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
dealloc_stack %1 : $*Optional<(E<ItemA, ItemB>, Int, Int, ResilientInt, @callee_guaranteed () -> ())>
%t = tuple ()
return %t: $()
}