Files
swift-mirror/test/embedded/modules-used2.swift
Doug Gregor b5e61cc4ad [SIL] Serialize the markedAsUsed bit in SILFunction
We were dropping this bit during serialization, so we don't know
whether the function was originally marked as "used".
2025-08-14 16:48:45 -07:00

40 lines
1.4 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -enable-experimental-feature Embedded -parse-as-library -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -enable-experimental-feature Embedded -parse-as-library -I %t %t/Main.swift -emit-sil | %FileCheck %s --check-prefix CHECK-SIL
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -enable-experimental-feature Embedded -parse-as-library -I %t %t/Main.swift -c -o %t/a.o
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_SymbolLinkageMarkers
// BEGIN MyModule.swift
@_used
@_cdecl("main")
func main() -> CInt {
print("main in a submodule")
return 0
}
@_used
func foo() {
}
// BEGIN Main.swift
import MyModule
// CHECK-SIL: // main()
// CHECK-SIL-NEXT: sil [used] @$e8MyModule4mains5Int32VyF : $@convention(thin) () -> Int32 {
// CHECK-SIL: // main
// CHECK-SIL-NEXT: sil [thunk] [used] @main : $@convention(c) () -> Int32
// CHECK-SIL: // foo()
// CHECK-SIL-NEXT: sil [used] @$e8MyModule3fooyyF : $@convention(thin) () -> () {
// CHECK: main in a submodule