mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We changed to `llvm.compiler.used` because of the behaviour of `gold`, which refuses to coalesce sections that have different `SHF_GNU_RETAIN` flags, which causes problems with metadata. Originally I thought we were going to have to generate two sections with distinct names and have the runtime look for both of them, but it turns out that the runtime only wants to see sections that have `SHF_GNU_RETAIN` in any case. It's really the reflection code that is interested in being able to see non-retained sections. The upshot is that we don't need to use `llvm.compiler.used`; it's just fine if we have duplicate sections, as long as the reflection code looks for them when it's inspecting an ELF image. This also means we no longer need to pass `-z nostart-stop-gc` to the linker if we're using `lld`. rdar://123504095
69 lines
2.7 KiB
Plaintext
69 lines
2.7 KiB
Plaintext
// RUN: %target-swift-frontend -disable-autolinking-runtime-compatibility-concurrency -disable-autolinking-runtime-compatibility-dynamic-replacements -runtime-compatibility-version none -primary-file %s -emit-ir | %FileCheck -check-prefix CHECK -check-prefix NEGATIVE -check-prefix CHECK-%target-object-format %s
|
|
|
|
// REQUIRES: CPU=x86_64
|
|
|
|
sil_stage canonical
|
|
import Builtin
|
|
import Swift
|
|
|
|
sil private @foo : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = function_ref @bar : $@convention(thin) () -> ()
|
|
%1 = apply %0() : $@convention(thin) () -> ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil public_external [serialized] @bar : $@convention(thin) () -> () {
|
|
bb0:
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil shared @baz : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = function_ref @bar : $@convention(thin) () -> ()
|
|
%1 = apply %0() : $@convention(thin) () -> ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil shared @qux : $@convention(thin) () -> () {
|
|
bb0:
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil hidden @fred : $@convention(thin) () -> () {
|
|
bb0:
|
|
%0 = function_ref @qux : $@convention(thin) () -> ()
|
|
%1 = apply %0() : $@convention(thin) () -> ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil @frieda : $@convention(thin) () -> () {
|
|
bb0:
|
|
%1 = tuple ()
|
|
return %1 : $()
|
|
}
|
|
|
|
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
|
|
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
|
|
%2 = integer_literal $Builtin.Int32, 0 // user: %3
|
|
%3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4
|
|
return %3 : $Int32 // id: %4
|
|
}
|
|
|
|
// CHECK-macho: @"\01l_entry_point" = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @main to i64), i64 ptrtoint (ptr @"\01l_entry_point" to i64)) to i32), i32 0 }, section "__TEXT, __swift5_entry, regular, no_dead_strip", align 4
|
|
// CHECK-elf: @"\01l_entry_point" = private constant { i32, i32 } { i32 trunc (i64 sub (i64 ptrtoint (ptr @main to i64), i64 ptrtoint (ptr @"\01l_entry_point" to i64)) to i32), i32 0 }, section "swift5_entry", align 4
|
|
|
|
// CHECK-macho: @llvm.used = appending global [4 x ptr] [ptr @frieda, ptr @main, ptr @"\01l_entry_point", ptr @__swift_reflection_version], section "llvm.metadata"
|
|
// CHECK-elf: @llvm.used = appending global [5 x ptr] [ptr @frieda, ptr @main, ptr @"\01l_entry_point", ptr @__swift_reflection_version, ptr @_swift1_autolink_entries], section "llvm.metadata"
|
|
|
|
// CHECK: define linkonce_odr hidden swiftcc void @qux()
|
|
// CHECK: define hidden swiftcc void @fred()
|
|
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @frieda()
|
|
// CHECK: define{{( dllexport)?}}{{( protected)?}} i32 @main
|
|
|
|
// NEGATIVE-NOT: @foo
|
|
// NEGATIVE-NOT: @bar
|
|
// NEGATIVE-NOT: @baz
|