Skip to content

Commit 51318b7

Browse files
authored
Merge pull request #74098 from apple/revert-74017-pointer-transparent
Revert "[stdlib] Mark some UnsafePointer APIs as transparent"
2 parents 2e3d42e + dabd99d commit 51318b7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

stdlib/public/core/UnsafePointer.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ extension UnsafePointer where Pointee: ~Copyable {
262262
/// This pointer must be a pointer to the start of a previously allocated
263263
/// memory block. The memory must not be initialized or `Pointee` must be a
264264
/// trivial type.
265+
@inlinable
265266
@_preInverseGenerics
266-
@_transparent
267267
public func deallocate() {
268268
// Passing zero alignment to the runtime forces "aligned
269269
// deallocation". Since allocation via `UnsafeMutable[Raw][Buffer]Pointer`
@@ -777,8 +777,8 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
777777
///
778778
/// - Parameter count: The amount of memory to allocate, counted in instances
779779
/// of `Pointee`.
780+
@inlinable
780781
@_preInverseGenerics
781-
@_transparent
782782
public static func allocate(
783783
capacity count: Int
784784
) -> UnsafeMutablePointer<Pointee> {
@@ -810,8 +810,8 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
810810
/// This pointer must be a pointer to the start of a previously allocated
811811
/// memory block. The memory must not be initialized or `Pointee` must be a
812812
/// trivial type.
813+
@inlinable
813814
@_preInverseGenerics
814-
@_transparent
815815
public func deallocate() {
816816
// Passing zero alignment to the runtime forces "aligned
817817
// deallocation". Since allocation via `UnsafeMutable[Raw][Buffer]Pointer`
@@ -898,7 +898,6 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
898898
/// - Parameters:
899899
/// - value: The instance to initialize this pointer's pointee to.
900900
@_alwaysEmitIntoClient
901-
@_transparent
902901
public func initialize(to value: consuming Pointee) {
903902
Builtin.initialize(value, self._rawValue)
904903
}
@@ -929,8 +928,8 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
929928
/// `move()`, the memory is uninitialized.
930929
///
931930
/// - Returns: The instance referenced by this pointer.
931+
@inlinable
932932
@_preInverseGenerics
933-
@_transparent
934933
public func move() -> Pointee {
935934
return Builtin.take(_rawValue)
936935
}
@@ -1163,9 +1162,9 @@ extension UnsafeMutablePointer where Pointee: ~Copyable {
11631162
/// not be negative.
11641163
/// - Returns: A raw pointer to the same address as this pointer. The memory
11651164
/// referenced by the returned raw pointer is still bound to `Pointee`.
1166-
@discardableResult
1165+
@inlinable
11671166
@_preInverseGenerics
1168-
@_transparent
1167+
@discardableResult
11691168
public func deinitialize(count: Int) -> UnsafeMutableRawPointer {
11701169
_debugPrecondition(count >= 0, "UnsafeMutablePointer.deinitialize with negative count")
11711170
// Note: When count is statically known to be 1 the compiler will optimize

test/SILOptimizer/stdlib/Cell.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public struct Cell<T: ~Copyable>: ~Copyable {
2020
// CHECK: bb0({{%.*}} : $*Cell<T>, [[VALUE:%.*]] : $*T, {{%.*}} : $@thin Cell<T>.Type):
2121
// CHECK: {{%.*}} = builtin "zeroInitializer"<Cell<T>>([[SELF:%.*]] : $*Cell<T>) : $()
2222
// CHECK-NEXT: [[RAW_LAYOUT_ADDR:%.*]] = builtin "addressOfRawLayout"<Cell<T>>([[SELF]] : $*Cell<T>) : $Builtin.RawPointer
23+
// CHECK-NEXT: [[POINTER:%.*]] = struct $UnsafeMutablePointer<T> ([[RAW_LAYOUT_ADDR]] : $Builtin.RawPointer)
24+
// Calling 'UnsafeMutablePointer<T>.initialize(to:)'
25+
// CHECK: {{%.*}} = apply {{%.*}}<T>([[VALUE]], [[POINTER]])
2326
// CHECK-LABEL: } // end sil function '$s4CellAAVAARi_zrlEyAByxGxcfC'
2427
@_transparent
2528
public init(_ value: consuming T) {

0 commit comments

Comments
 (0)