Skip to content

Commit e631c66

Browse files
committed
[stdlib/private][os log] Annotate tiny helper functions in the new
os log overlay @_transparent so that they will be inlined in their callers even annotated as @_optimize(none). Make the OSLogPrototypeCompileTest.swift test suite check only the output of the OSLogOptimization pass instead of the output of the Onone pipeline. This will make the tes more resilient to adding mandatory optimizations later in the pass pipeline. Also, remove a duplicate test from the OSLogPrototypeExecTest suite.
1 parent b4771c2 commit e631c66

File tree

5 files changed

+154
-103
lines changed

5 files changed

+154
-103
lines changed

stdlib/private/OSLog/OSLogIntegerTypes.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ extension OSLogInterpolation {
5858
appendInteger(number, format: format, privacy: privacy)
5959
}
6060

61+
@_semantics("constant_evaluable")
62+
@inlinable
63+
@_optimize(none)
64+
public mutating func appendInterpolation(
65+
_ number: @autoclosure @escaping () -> UInt,
66+
format: IntFormat = .decimal,
67+
privacy: Privacy = .public
68+
) {
69+
appendInteger(number, format: format, privacy: privacy)
70+
}
71+
6172
/// Given an integer, create and append a format specifier for the integer to the
6273
/// format string property. Also, append the integer along with necessary headers
6374
/// to the OSLogArguments property.
@@ -154,10 +165,11 @@ extension OSLogArguments {
154165
}
155166

156167
/// Return the number of bytes needed for serializing an integer argument as
157-
/// specified by os_log. This function must be constant evaluable.
158-
@_semantics("constant_evaluable")
159-
@inlinable
160-
@_optimize(none)
168+
/// specified by os_log. This function must be constant evaluable. Note that
169+
/// it is marked transparent instead of @inline(__always) as it is used in
170+
/// optimize(none) functions.
171+
@_transparent
172+
@usableFromInline
161173
internal func sizeForEncoding<T>(
162174
_ type: T.Type
163175
) -> Int where T : FixedWidthInteger {

stdlib/private/OSLog/OSLogMessage.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ public enum Privacy {
4848
@_optimize(none)
4949
public var maxOSLogArgumentCount: UInt8 { return 48 }
5050

51-
@_semantics("constant_evaluable")
52-
@inlinable
53-
@_optimize(none)
51+
/// Note that this is marked transparent instead of @inline(__always) as it is
52+
/// used in optimize(none) functions.
53+
@_transparent
54+
@usableFromInline
5455
internal var logBitsPerByte: Int { return 3 }
5556

5657
/// Represents a string interpolation passed to the log APIs.

stdlib/private/OSLog/OSLogStringTypes.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ extension OSLogArguments {
101101
/// bitWidth property, and since MemoryLayout is not supported by the constant
102102
/// evaluator, this function returns the byte size of Int, which must equal the
103103
/// word length of the target architecture and hence the pointer size.
104-
/// This function must be constant evaluable.
105-
@_semantics("constant_evaluable")
106-
@inlinable
107-
@_optimize(none)
104+
/// This function must be constant evaluable. Note that it is marked transparent
105+
/// instead of @inline(__always) as it is used in optimize(none) functions.
106+
@_transparent
107+
@usableFromInline
108108
internal func pointerSizeInBytes() -> Int {
109109
return Int.bitWidth &>> logBitsPerByte
110110
}

0 commit comments

Comments
 (0)