mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85074 from kubamracek/section
SE-0492: Stabilize @_section/@_used into @section/@used
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
|
||||
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -O %s -emit-ir | %FileCheck %s --check-prefix=CHECK-IR
|
||||
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -O %s -c -o %t/a.o
|
||||
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -module-name main -O %s -emit-ir | %FileCheck %s --check-prefix=CHECK-IR
|
||||
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -module-name main -O %s -c -o %t/a.o
|
||||
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o -o %t/a.out -dead_strip
|
||||
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | sort | %FileCheck %s --check-prefix=CHECK-NM
|
||||
// RUN: %target-run %t/a.out | %FileCheck %s
|
||||
@@ -9,11 +9,10 @@
|
||||
// REQUIRES: swift_in_compiler
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: swift_feature_Embedded
|
||||
// REQUIRES: swift_feature_SymbolLinkageMarkers
|
||||
|
||||
public func a_this_is_unused() { }
|
||||
|
||||
@_used
|
||||
@used
|
||||
public func b_this_is_unused_but_explicitly_retained() { }
|
||||
|
||||
// CHECK-IR: define {{.*}}@"$e4main16a_this_is_unusedyyF"()
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
// REQUIRES: swift_feature_DeferredCodeGen
|
||||
// REQUIRES: swift_feature_CDecl
|
||||
// REQUIRES: swift_feature_CImplementation
|
||||
// REQUIRES: swift_feature_SymbolLinkageMarkers
|
||||
|
||||
// RUN: %target-swift-frontend -emit-ir -o - %s -I %S/Inputs -package-name MyPackage -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -enable-experimental-feature CDecl -enable-experimental-feature CImplementation -enable-experimental-feature SymbolLinkageMarkers -parse-as-library | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-ir -o - %s -I %S/Inputs -package-name MyPackage -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -enable-experimental-feature CDecl -enable-experimental-feature CImplementation -parse-as-library | %FileCheck %s
|
||||
|
||||
import MyModuleExports
|
||||
|
||||
@@ -61,21 +60,21 @@ internal func clib_func3() -> Double { 0 }
|
||||
internal func clib_func4() -> Double { 0 }
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// @_section causes symbol emission
|
||||
// @section causes symbol emission
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// CHECK: define {{(protected |dllexport )?}}swiftcc void @"$e1c15symbolInSectionyyF"
|
||||
@_section("__TEXT,__mysection")
|
||||
@section("__TEXT,__mysection")
|
||||
public func symbolInSection() { }
|
||||
|
||||
// CHECK: define hidden swiftcc void @"$e1c23internalSymbolInSectionyyF"
|
||||
@_section("__TEXT,__mysection")
|
||||
@section("__TEXT,__mysection")
|
||||
func internalSymbolInSection() { }
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// @_used causes symbol emission
|
||||
// @used causes symbol emission
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// CHECK: define hidden swiftcc void @"$e1c10usedSymbolyyF"
|
||||
@_used
|
||||
@used
|
||||
func usedSymbol() { }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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-swift-frontend -enable-experimental-feature Embedded -parse-as-library -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift
|
||||
// RUN: %target-swift-frontend -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 Embedded -parse-as-library -I %t %t/Main.swift -c -o %t/a.o
|
||||
// RUN: %target-clang %t/a.o -o %t/a.out
|
||||
// RUN: %target-run %t/a.out | %FileCheck %s
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
// REQUIRES: executable_test
|
||||
// REQUIRES: OS=macosx
|
||||
// REQUIRES: swift_feature_Embedded
|
||||
// REQUIRES: swift_feature_SymbolLinkageMarkers
|
||||
|
||||
// BEGIN MyModule.swift
|
||||
|
||||
@_used
|
||||
@_section("__DATA,__mysection")
|
||||
@used
|
||||
@section("__DATA,__mysection")
|
||||
let i_am_not_referenced = 42
|
||||
|
||||
// BEGIN Main.swift
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
// 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-swift-frontend -enable-experimental-feature Embedded -parse-as-library -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift
|
||||
// RUN: %target-swift-frontend -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 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
|
||||
@used
|
||||
@_cdecl("main")
|
||||
func main() -> CInt {
|
||||
print("main in a submodule")
|
||||
return 0
|
||||
}
|
||||
|
||||
@_used
|
||||
@used
|
||||
func foo() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user