mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
For types like `Atomic` and `Mutex`, we want to know that even though they are technically bitwise-takable, they differ from other bitwise-takable types until this point because they are not also "bitwise-borrowable"; while borrowed, they are pinned in memory, so they cannot be passed by value as a borrowed parameter, unlike copyable bitwise-takable types. Add a bit to the value witness table flags to record this. Note that this patch does not include any accompanying runtime support for propagating the flag into runtime-instantiated type metadata. There isn't yet any runtime functionality that varies based on this flag, so that can be implemented separately. rdar://136396806
39 lines
1.6 KiB
Swift
39 lines
1.6 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %{python} %utils/chex.py < %s > %t/existential-bitwise-borrowability.swift
|
|
// RUN: %target-swift-frontend -enable-experimental-feature RawLayout -enable-experimental-feature ValueGenerics -emit-ir -disable-availability-checking -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %t/existential-bitwise-borrowability.swift | %FileCheck %t/existential-bitwise-borrowability.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
|
|
|
// Copyable existentials are bitwise-borrowable (because copyable types are
|
|
// always bitwise-borrowable if they're bitwise-takable, and only bitwise-takable
|
|
// values are stored inline in existentials). Noncopyable existentials are
|
|
// not (since types like Atomic and Mutex can be stored inline in their
|
|
// buffers).
|
|
|
|
// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}3FooVWV" = {{.*}} %swift.vwtable
|
|
// size
|
|
// CHECK-64-SAME: , {{i64|i32}} 32
|
|
// CHECK-32-SAME: , {{i64|i32}} 16
|
|
// stride
|
|
// CHECK-64-SAME: , {{i64|i32}} 32
|
|
// CHECK-32-SAME: , {{i64|i32}} 16
|
|
// flags: word alignment, noncopyable, non-POD, non-inline-storage
|
|
// CHECK-64-SAME: , <i32 0x830007>
|
|
// CHECK-32-SAME: , <i32 0x830003>
|
|
struct Foo: ~Copyable {
|
|
var x: Any
|
|
}
|
|
|
|
// CHECK-LABEL: @"$s{{[A-Za-z0-9_]*}}3BarVWV" = {{.*}} %swift.vwtable
|
|
// size
|
|
// CHECK-64-SAME: , {{i64|i32}} 32
|
|
// CHECK-32-SAME: , {{i64|i32}} 16
|
|
// stride
|
|
// CHECK-64-SAME: , {{i64|i32}} 32
|
|
// CHECK-32-SAME: , {{i64|i32}} 16
|
|
// flags: word alignment, non-bitwise-borrowable, noncopyable, non-POD, non-inline-storage
|
|
// CHECK-64-SAME: , <i32 0x1830007>
|
|
// CHECK-32-SAME: , <i32 0x1830003>
|
|
struct Bar: ~Copyable {
|
|
var x: any ~Copyable
|
|
}
|
|
|