diff --git a/stdlib/private/OSLog/OSLog.swift b/stdlib/private/OSLog/OSLog.swift index c0661f3e43e..d4da553b17a 100644 --- a/stdlib/private/OSLog/OSLog.swift +++ b/stdlib/private/OSLog/OSLog.swift @@ -66,6 +66,7 @@ internal func osLog( let preamble = message.interpolation.preamble let argumentCount = message.interpolation.argumentCount let bufferSize = message.bufferSize + let uint32bufferSize = UInt32(bufferSize) let argumentClosures = message.interpolation.arguments.argumentClosures let formatStringPointer = _getGlobalStringTablePointer(formatString) @@ -91,7 +92,7 @@ internal func osLog( logLevel, formatStringPointer, bufferMemory, - UInt32(bufferSize)) + uint32bufferSize) // The following operation extends the lifetime of stringStorageObjects // and also of the objects stored in it till this point. diff --git a/stdlib/private/OSLog/OSLogIntegerTypes.swift b/stdlib/private/OSLog/OSLogIntegerTypes.swift index d1263182e1e..673a22ce7ac 100644 --- a/stdlib/private/OSLog/OSLogIntegerTypes.swift +++ b/stdlib/private/OSLog/OSLogIntegerTypes.swift @@ -155,9 +155,8 @@ extension OSLogArguments { /// Return the number of bytes needed for serializing an integer argument as /// specified by os_log. This function must be constant evaluable. -@inlinable @_semantics("constant_evaluable") -@_effects(readonly) +@inlinable @_optimize(none) internal func sizeForEncoding( _ type: T.Type @@ -167,8 +166,9 @@ internal func sizeForEncoding( /// Serialize an integer at the buffer location that `position` points to and /// increment `position` by the byte size of `T`. -@usableFromInline +@inlinable @_alwaysEmitIntoClient +@inline(__always) internal func serialize( _ value: T, at bufferPosition: inout ByteBufferPointer diff --git a/stdlib/private/OSLog/OSLogMessage.swift b/stdlib/private/OSLog/OSLogMessage.swift index 1a362f0d4e9..7d27b797700 100644 --- a/stdlib/private/OSLog/OSLogMessage.swift +++ b/stdlib/private/OSLog/OSLogMessage.swift @@ -43,11 +43,14 @@ public enum Privacy { /// Maximum number of arguments i.e., interpolated expressions that can /// be used in the string interpolations passed to the log APIs. /// This limit is imposed by the ABI of os_log. -@_transparent +@_semantics("constant_evaluable") +@inlinable +@_optimize(none) public var maxOSLogArgumentCount: UInt8 { return 48 } -@usableFromInline -@_transparent +@_semantics("constant_evaluable") +@inlinable +@_optimize(none) internal var logBitsPerByte: Int { return 3 } /// Represents a string interpolation passed to the log APIs. @@ -303,7 +306,8 @@ public struct OSLogMessage : /// The byte size of the buffer that will be passed to the C os_log ABI. /// It will contain the elements of `interpolation.arguments` and the two /// summary bytes: preamble and argument count. - @_transparent + @_semantics("constant_evaluable") + @inlinable @_optimize(none) public var bufferSize: Int { return interpolation.totalBytesForSerializingArguments + 2 @@ -353,8 +357,9 @@ internal struct OSLogArguments { /// Serialize a UInt8 value at the buffer location pointed to by `bufferPosition`, /// and increment the `bufferPosition` with the byte size of the serialized value. -@usableFromInline +@inlinable @_alwaysEmitIntoClient +@inline(__always) internal func serialize( _ value: UInt8, at bufferPosition: inout ByteBufferPointer) diff --git a/stdlib/private/OSLog/OSLogStringTypes.swift b/stdlib/private/OSLog/OSLogStringTypes.swift index 492a03c000c..bac0a624b76 100644 --- a/stdlib/private/OSLog/OSLogStringTypes.swift +++ b/stdlib/private/OSLog/OSLogStringTypes.swift @@ -102,10 +102,9 @@ extension OSLogArguments { /// evaluator, this function returns the byte size of Int, which must equal the /// word length of the target architecture and hence the pointer size. /// This function must be constant evaluable. +@_semantics("constant_evaluable") @inlinable @_optimize(none) -@_effects(readonly) -@_semantics("constant_evaluable") internal func sizeForEncoding() -> Int { return Int.bitWidth &>> logBitsPerByte } @@ -114,8 +113,9 @@ internal func sizeForEncoding() -> Int { /// pointed by `bufferPosition`. When necessary, this function would copy the /// string contents to a storage with a stable pointer. If that happens, a reference /// to the storage will be added to `storageObjects`. -@usableFromInline +@inlinable @_alwaysEmitIntoClient +@inline(__always) internal func serialize( _ stringValue: String, at bufferPosition: inout ByteBufferPointer, diff --git a/test/SILOptimizer/OSLogConstantEvaluableTest.swift b/test/SILOptimizer/OSLogConstantEvaluableTest.swift index b6491f18506..6a139e9a5c5 100644 --- a/test/SILOptimizer/OSLogConstantEvaluableTest.swift +++ b/test/SILOptimizer/OSLogConstantEvaluableTest.swift @@ -4,7 +4,7 @@ // Run the (mandatory) passes on which constant evaluator depends, and run the // constant evaluator on the SIL produced after the dependent passes are run. // -// RUN: %target-sil-opt -silgen-cleanup -raw-sil-inst-lowering -allocbox-to-stack -mandatory-inlining -constexpr-limit 1024 -test-constant-evaluable-subset %t/OSLogConstantEvaluableTest_silgen.sil > %t/OSLogConstantEvaluableTest.sil 2> %t/error-output +// RUN: %target-sil-opt -silgen-cleanup -raw-sil-inst-lowering -allocbox-to-stack -mandatory-inlining -constexpr-limit 2048 -test-constant-evaluable-subset %t/OSLogConstantEvaluableTest_silgen.sil > %t/OSLogConstantEvaluableTest.sil 2> %t/error-output // // RUN: %FileCheck %s < %t/error-output //