1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
// 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
|