mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This allows external tools to locate the metadata pointer without needing to call the accessor function. This is only useful for non-generic types, so we borrow the HasCanonicalMetadataPrespecializations flag to indicate the presence of this pointer on non-generic types, and it continues to indicate the presence of prespecializations for generic types. Only emit this pointer for internal/private types with no runtime initialization. Public type metadata can be found with the symbol, and it's not useful for types that require runtime initialization.
12 lines
934 B
Swift
12 lines
934 B
Swift
// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %module-target-future -emit-ir %s -emit-singleton-metadata-pointer | %FileCheck %s -DINT=i%target-ptrsize -DALIGNMENT=%target-alignment --check-prefix=CHECK-%target-ptrsize --check-prefix=CHECK --check-prefix=CHECK-%target-vendor --dump-input=always
|
|
|
|
// CHECK: @"$s4main23PrivateNongenericStructVMn" =
|
|
// CHECK-SAME: hidden constant <{ i32, i32, i32, i32, i32, i32, i32, i32 }>
|
|
// -- flags: struct, unique, has singleton metadata pointer
|
|
// CHECK-SAME: <{ i32 524369,
|
|
// -- 32-bit relative pointer to metadata
|
|
// CHECK-64-SAME: i32 trunc (i64 sub (i64 ptrtoint (ptr getelementptr inbounds (<{ {{.*}} }>, ptr @"$s4main23PrivateNongenericStructVMf", i32 0, i32 2) to i64)
|
|
// CHECK-32-SAME: i32 sub (i32 ptrtoint (ptr getelementptr inbounds (<{ {{.*}} }>, ptr @"$s4main23PrivateNongenericStructVMf", i32 0, i32 2) to i32)
|
|
|
|
internal struct PrivateNongenericStruct {}
|