Skip to content

[4.2] Cherry-pick dropping @inlinable and other cleanup #16593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/SIL/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3008,9 +3008,12 @@ void SILSpecializeAttr::print(llvm::raw_ostream &OS) const {
SILFunction *F = getFunction();
assert(F);
auto GenericEnv = F->getGenericEnvironment();
assert(GenericEnv);
interleave(getRequirements(),
[&](Requirement req) {
if (!GenericEnv) {
req.print(OS, SubPrinter);
return;
}
// Use GenericEnvironment to produce user-friendly
// names instead of something like t_0_0.
auto FirstTy = GenericEnv->getSugaredType(req.getFirstType());
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/ArrayBuffer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ extension _ArrayBuffer {
// checks one element. The reason for this is that the ARC optimizer does not
// handle loops atm. and so can get blocked by the presence of a loop (over
// the range). This loop is not necessary for a single element access.
@inlinable
@inline(never)
@usableFromInline
internal func _typeCheckSlowPath(_ index: Int) {
if _fastPath(_isNative) {
let element: AnyObject = cast(toBufferOf: AnyObject.self)._native[index]
Expand Down Expand Up @@ -389,8 +389,8 @@ extension _ArrayBuffer {
return unsafeBitCast(_getElementSlowPath(i), to: Element.self)
}

@inlinable
@inline(never)
@inlinable // @specializable
internal func _getElementSlowPath(_ i: Int) -> AnyObject {
_sanityCheck(
_isClassOrObjCExistential(Element.self),
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/ArrayBufferProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ extension _ArrayBufferProtocol where Indices == Range<Int>{
}

// Make sure the compiler does not inline _copyBuffer to reduce code size.
@inlinable
@inline(never)
@usableFromInline
internal init(copying buffer: Self) {
let newBuffer = _ContiguousArrayBuffer<Element>(
_uninitializedCount: buffer.count, minimumCapacity: buffer.count)
Expand Down
14 changes: 7 additions & 7 deletions stdlib/public/core/Arrays.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ extension ${Self} : RangeReplaceableCollection, ArrayProtocol {
}
}

@inlinable
@inline(never)
@usableFromInline
internal static func _allocateBufferUninitialized(
minimumCapacity: Int
) -> _Buffer {
Expand Down Expand Up @@ -1337,8 +1337,8 @@ extension ${Self} : RangeReplaceableCollection, ArrayProtocol {
/// Copy the contents of the current buffer to a new unique mutable buffer.
/// The count of the new buffer is set to `oldCount`, the capacity of the
/// new buffer is big enough to hold 'oldCount' + 1 elements.
@inlinable
@inline(never)
@inlinable // @specializable
internal mutating func _copyToNewBuffer(oldCount: Int) {
let newCount = oldCount + 1
var newBuffer = _buffer._forceCreateUniqueMutableBuffer(
Expand Down Expand Up @@ -1875,8 +1875,8 @@ internal struct _InitializeMemoryFromCollection<
}

extension _ArrayBufferProtocol {
@inlinable
@inline(never)
@usableFromInline
internal mutating func _arrayOutOfPlaceReplace<C : Collection>(
_ bounds: Range<Int>,
with newValues: C,
Expand Down Expand Up @@ -1989,8 +1989,8 @@ extension _ArrayBufferProtocol {
/// The formula used to compute the new buffers capacity is:
/// max(requiredCapacity, source.capacity) if newCount <= source.capacity
/// max(requiredCapacity, _growArrayCapacity(source.capacity)) otherwise
@inlinable
@inline(never)
@inlinable // @specializable
internal func _forceCreateUniqueMutableBuffer(
newCount: Int, requiredCapacity: Int
) -> _ContiguousArrayBuffer<Element> {
Expand All @@ -2005,8 +2005,8 @@ extension _ArrayBufferProtocol {
/// The formula used to compute the new buffers capacity is:
/// max(minNewCapacity, source.capacity) if minNewCapacity <= source.capacity
/// max(minNewCapacity, _growArrayCapacity(source.capacity)) otherwise
@inlinable
@inline(never)
@inlinable // @specializable
internal func _forceCreateUniqueMutableBuffer(
countForNewBuffer: Int, minNewCapacity: Int
) -> _ContiguousArrayBuffer<Element> {
Expand Down Expand Up @@ -2054,8 +2054,8 @@ extension _ArrayBufferProtocol {
///
/// As an optimization, may move elements out of source rather than
/// copying when it isUniquelyReferenced.
@inlinable
@inline(never)
@inlinable // @specializable
internal mutating func _arrayOutOfPlaceUpdate<Initializer>(
_ dest: inout _ContiguousArrayBuffer<Element>,
_ headCount: Int, // Count of initial source elements to copy/move
Expand Down Expand Up @@ -2138,8 +2138,8 @@ internal struct _IgnorePointer<T> : _PointerFunction {
}

extension _ArrayBufferProtocol {
@inlinable
@inline(never)
@usableFromInline
internal mutating func _outlinedMakeUniqueBuffer(bufferCount: Int) {

if _fastPath(
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Dictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3299,8 +3299,8 @@ internal enum _VariantDictionaryBuffer<Key: Hashable, Value>: _HashBuffer {
}

#if _runtime(_ObjC)
@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal mutating func migrateDataToNativeBuffer(
_ cocoaBuffer: _CocoaDictionaryBuffer
) {
Expand Down Expand Up @@ -3464,8 +3464,8 @@ internal enum _VariantDictionaryBuffer<Key: Hashable, Value>: _HashBuffer {
}

#if _runtime(_ObjC)
@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal static func maybeGetFromCocoaBuffer(
_ cocoaBuffer: CocoaBuffer, forKey key: Key
) -> Value? {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/ExistentialCollection.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ from gyb_stdlib_support import (

import SwiftShims

@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal func _abstract(
file: StaticString = #file,
line: UInt = #line
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/IntegerParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ extension FixedWidthInteger {
// _parseASCII function thunk that prevents inlining used as an implementation
// detail for FixedWidthInteger.init(_: radix:) on the slow path to save code
// size.
@inlinable // FIXME(sil-serialize-all)
@_semantics("optimize.sil.specialize.generic.partial.never")
@inline(never)
@usableFromInline
internal static func _parseASCIISlowPath<
CodeUnits : IteratorProtocol, Result: FixedWidthInteger
>(
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Mirror.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public struct Mirror {

@_semantics("optimize.sil.specialize.generic.never")
@inline(never)
@inlinable // FIXME(sil-serialize-all)
@usableFromInline
internal static func _superclassIterator<Subject>(
_ subject: Subject, _ ancestorRepresentation: AncestorRepresentation
) -> () -> Mirror? {
Expand Down
5 changes: 2 additions & 3 deletions stdlib/public/core/OutputStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ internal func _print_unlocked<T, TargetStream : TextOutputStream>(
///
/// This function is forbidden from being inlined because when building the
/// standard library inlining makes us drop the special semantics.
@inlinable
@inline(never) @effects(readonly)
@usableFromInline
internal func _toStringReadOnlyStreamable<
T : TextOutputStreamable
>(_ x: T) -> String {
Expand All @@ -425,8 +425,8 @@ internal func _toStringReadOnlyStreamable<
return result
}

@inlinable
@inline(never) @effects(readonly)
@usableFromInline
internal func _toStringReadOnlyPrintable<
T : CustomStringConvertible
>(_ x: T) -> String {
Expand All @@ -437,7 +437,6 @@ internal func _toStringReadOnlyPrintable<
// `debugPrint`
//===----------------------------------------------------------------------===//

@inlinable // FIXME(sil-serialize-all)
@_semantics("optimize.sil.specialize.generic.never")
@inline(never)
public func _debugPrint_unlocked<T, TargetStream : TextOutputStream>(
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Set.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,8 @@ internal enum _VariantSetBuffer<Element: Hashable>: _HashBuffer {
}

#if _runtime(_ObjC)
@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal mutating func migrateDataToNativeBuffer(
_ cocoaBuffer: _CocoaSetBuffer
) {
Expand Down Expand Up @@ -2993,8 +2993,8 @@ internal enum _VariantSetBuffer<Element: Hashable>: _HashBuffer {
}

#if _runtime(_ObjC)
@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal static func maybeGetFromCocoaBuffer(
_ cocoaBuffer: CocoaBuffer, forKey key: Key
) -> Value? {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/ThreadLocalStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ internal let _tlsKey: __swift_thread_key_t = {
return key
}()

@inlinable // FIXME(sil-serialize-all)
@inline(never)
@usableFromInline
internal func _initializeThreadLocalStorage()
-> UnsafeMutablePointer<_ThreadLocalStorage>
{
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/UTF8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ extension UTF8.ReverseParser : Unicode.Parser, _UTFParser {
/// Returns the length of the invalid sequence that ends with the LSB of
/// buffer.
@inline(never)
@inlinable // FIXME(sil-serialize-all)
@usableFromInline
internal func _invalidLength() -> UInt8 {
if _buffer._storage & 0b0__1111_0000__1100_0000
== 0b0__1110_0000__1000_0000 {
Expand Down Expand Up @@ -254,7 +254,7 @@ extension Unicode.UTF8.ForwardParser : Unicode.Parser, _UTFParser {
/// Returns the length of the invalid sequence that starts with the LSB of
/// buffer.
@inline(never)
@inlinable // FIXME(sil-serialize-all)
@usableFromInline
internal func _invalidLength() -> UInt8 {
if _buffer._storage & 0b0__1100_0000__1111_0000
== 0b0__1000_0000__1110_0000 {
Expand Down
3 changes: 0 additions & 3 deletions test/Sema/fixed_ambiguities/rdar35623181.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s

// XFAIL: *
// ^ SR-7673

extension Sequence where Element == String {
func record() -> String {
// CHECK: function_ref @$Ss20LazySequenceProtocolPsE3mapys0a3MapB0Vy8ElementsQzqd__Gqd__7ElementQzclF : $@convention(method) <τ_0_0 where τ_0_0 : LazySequenceProtocol><τ_1_0> (@guaranteed @callee_guaranteed (@in_guaranteed τ_0_0.Element) -> @out τ_1_0, @in_guaranteed τ_0_0) -> @out LazyMapSequence<τ_0_0.Elements, τ_1_0
Expand Down
12 changes: 6 additions & 6 deletions test/Serialization/serialize_attr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@

//CHECK-DAG: @_semantics("crazy") func foo()
@inlinable
@usableFromInline
@_semantics("crazy") func foo() -> Int { return 5}

// @_optimize
// -----------------------------------------------------------------------------

//CHECK-DAG: @_optimize(none) func test_onone()
@inlinable
@usableFromInline
@_optimize(none)
func test_onone() -> Int { return 5}

//CHECK-DAG: @_optimize(speed) func test_ospeed()
@inlinable
@usableFromInline
@_optimize(speed)
func test_ospeed() -> Int { return 5}

//CHECK-DAG: @_optimize(size) func test_osize()
@inlinable
@usableFromInline
@_optimize(size)
func test_osize() -> Int { return 5}

Expand All @@ -42,9 +38,14 @@ func test_osize() -> Int { return 5}
// CHECK-DAG: @_specialize(exported: false, kind: full, where T == Int, U == Float)
// CHECK-DAG: func specializeThis<T, U>(_ t: T, u: U)
@inlinable
@_specialize(where T == Int, U == Float)
func specializeThis<T, U>(_ t: T, u: U) {
specializeThat(t, u: u)
}

@usableFromInline
@_specialize(where T == Int, U == Float)
func specializeThis<T, U>(_ t: T, u: U) {}
func specializeThat<T, U>(_ t: T, u: U) {}

public protocol PP {
associatedtype PElt
Expand All @@ -71,7 +72,6 @@ public struct GG<T : PP> {}
// CHECK-DAG: @inline(never) func foo<U>(_ u: U, g: GG<T>) -> (U, GG<T>) where U : QQ
public class CC<T : PP> {
@inlinable
@usableFromInline
@inline(never)
@_specialize(where T==RR, U==SS)
func foo<U : QQ>(_ u: U, g: GG<T>) -> (U, GG<T>) {
Expand Down