mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public). In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level. Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect, because everything was public anyway. For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all, i.e. for the stdlib. For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions. The benefits of this change are: *) Enable to eliminate unused private and internal functions *) It should be possible now to use private in the stdlib *) The symbol linkage is as one would expect (previously almost all symbols were public). More details: Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default linkage instead of linkonce_odr,hidden, i.e. they have public visibility. The reason is: if such a function is called from another fragile function (in the same module), then it has to be visible from a third module, in case the fragile caller is inlined but not the specialized function. I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed. The -sil-serialize-all option is now handled at SILGen and not at the Serializer. This means that test files in sil format which are compiled with -sil-serialize-all must have the [fragile] attribute set for all functions and globals. The -disable-access-control option doesn't help anymore if the accessed module is not compiled with -sil-serialize-all, because the linker will complain about unresolved symbols. A final note: I tried to consider all the implications of this change, but it's not a low-risk change. If you have any comments, please let me know. Swift SVN r22215
85 lines
2.4 KiB
Swift
85 lines
2.4 KiB
Swift
//===--- OpaqueIdentityFunctions.swift ------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
@asmname("swift_stdlib_getPointer")
|
|
func _stdlib_getPointer(x: COpaquePointer) -> COpaquePointer
|
|
|
|
public func _opaqueIdentity<T>(x: T) -> T {
|
|
var ptr = UnsafeMutablePointer<T>.alloc(1)
|
|
ptr.initialize(x)
|
|
let result =
|
|
UnsafeMutablePointer<T>(_stdlib_getPointer(COpaquePointer(ptr))).memory
|
|
ptr.destroy()
|
|
ptr.dealloc(1)
|
|
return result
|
|
}
|
|
|
|
func _blackHolePtr<T>(x: UnsafePointer<T>) {
|
|
_stdlib_getPointer(COpaquePointer(x))
|
|
}
|
|
|
|
public func _blackHole<T>(var x: T) {
|
|
_blackHolePtr(&x)
|
|
}
|
|
|
|
@inline(never)
|
|
public func getInt8(x: Int8) -> Int8 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getInt16(x: Int16) -> Int16 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getInt32(x: Int32) -> Int32 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getInt64(x: Int64) -> Int64 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getInt(x: Int) -> Int { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getWord(x: Word) -> Word { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUInt8(x: UInt8) -> UInt8 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUInt16(x: UInt16) -> UInt16 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUInt32(x: UInt32) -> UInt32 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUInt64(x: UInt64) -> UInt64 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUInt(x: UInt) -> UInt { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getUWord(x: UWord) -> UWord { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getFloat32(x: Float32) -> Float32 { return _opaqueIdentity(x) }
|
|
|
|
@inline(never)
|
|
public func getFloat64(x: Float64) -> Float64 { return _opaqueIdentity(x) }
|
|
|
|
#if arch(i386) || arch(x86_64)
|
|
@inline(never)
|
|
public func getFloat80(x: Float80) -> Float80 { return _opaqueIdentity(x) }
|
|
#endif
|
|
|
|
public func getPointer(x: COpaquePointer) -> COpaquePointer {
|
|
return _opaqueIdentity(x)
|
|
}
|
|
|