Files
swift-mirror/test/IRGen/reparenting.swift
Kavon Farvardin 28cac41ef9 Reparenting: sign the conformance descriptor
The protocol conformance descriptor passed to swift_getWitnessTable
needs to be signed on arm64e. When reparenting a protocol P with
new parent Q, we emit a small "default conformance accessor" function
that instantiates the type's witness table for Q using its witness
table for P, at runtime. This accessor is only used if the type
conforming to P comes from a module that hasn't been rebuilt since
the reparenting happened.

resolves rdar://171661924
2026-03-03 18:13:53 -08:00

42 lines
1.9 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-library-evolution -module-name A -primary-file %s -emit-ir -enable-experimental-feature Reparenting -o %t/out.ll
// RUN: %FileCheck %s --check-prefix=CHECK-%target-cpu --check-prefix=CHECK < %t/out.ll
// RUN: %target-swift-frontend -enable-relative-protocol-witness-tables -enable-library-evolution -module-name A -primary-file %s -emit-ir -enable-experimental-feature Reparenting -o %t/relative.ll
// RUN: %FileCheck %s --check-prefix=RELATIVE --check-prefix=CHECK < %t/relative.ll
// REQUIRES: swift_feature_Reparenting
// REQUIRES: CPU=x86_64 || CPU=arm64 || CPU=arm64e
@reparentable public protocol NewProto {
associatedtype Thing: Equatable
func new() -> Thing
}
extension Existing: @reparented NewProto where Thing == String {
public func new() -> Thing { return "new" }
}
public protocol Existing: NewProto {
associatedtype Thing: Equatable = String
func existing() -> Thing
}
// CHECK: @"default associated conformance1A8NewProto" = linkonce_odr hidden constant
// CHECK-SAME: ptr @"$s1A8ExistingPxAA8NewProtoTN"
// CHECK: @"$s1A8ExistingMp" =
// CHECK-SAME: @"default associated conformance1A8NewProto"
// CHECK-LABEL: define internal swiftcc ptr @"$s1A8ExistingPxAA8NewProtoTN"(ptr %0, ptr %1, ptr %2){{.*}} {
// CHECK: %instantiationArgs = alloca ptr, align 8
// CHECK: store ptr %2, ptr %instantiationArgs, align 8
// CHECK-x86_64: %3 = call ptr @swift_getWitnessTable(ptr @"$s1A8Existing_pAA8NewProtoAASS5ThingRtzrlMc", ptr %0, ptr %instantiationArgs)
// CHECK-arm64: %3 = call ptr @swift_getWitnessTable(ptr @"$s1A8Existing_pAA8NewProtoAASS5ThingRtzrlMc", ptr %0, ptr %instantiationArgs)
// CHECK-arm64e: %3 = call ptr @swift_getWitnessTable(ptr @"$s1A8Existing_pAA8NewProtoAASS5ThingRtzrlMc.ptrauth", ptr %0, ptr %instantiationArgs)
// RELATIVE: %3 = call ptr @swift_getWitnessTableRelative(ptr @"$s1A8Existing_pAA8NewProtoAASS5ThingRtzrlMc
// CHECK: ret ptr %3
// CHECK: }