mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This commit adds -sil-output-path and -ir-output-path frontend options that allow generating SIL and LLVM IR files as supplementary outputs during normal compilation. These options can be useful for debugging and analysis tools workflows that need access to intermediate compilation artifacts without requiring separate compiler invocations. Expected behaviour: Primary File mode: - SIL: Generates one .sil file per source file - IR: Generates one .ll file per source file Single-threaded WMO mode: - SIL: Generates one .sil file for the entire module - IR: Generates one .ll file for the entire module Multi-threaded WMO mode: - SIL: Generates one .sil file for the entire module - IR: Generates separate .ll files per source file File Maps with WMO: - Both SIL and IR outputs using first entry's naming, which is consistent with the behaviour of other supplementary outputs. rdar://160297898
47 lines
2.3 KiB
Swift
47 lines
2.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// Test that SIL and IR files can be requested via output file map
|
|
|
|
// Test primary file compilation with both SIL and IR in file map
|
|
// RUN: echo '{"%/s": {"sil": "%/t/primary.sil", "llvm-ir": "%/t/primary.ll"}, "%/S/../Driver/Inputs/main.swift": {"sil": "%/t/main.sil", "llvm-ir": "%/t/main.ll"}}' > %t/multi-map.json
|
|
// RUN: %target-swift-frontend -emit-object -supplementary-output-file-map %t/multi-map.json -primary-file %/s %/S/../Driver/Inputs/main.swift -o %t/primary.o -module-name test
|
|
// RUN: test -f %t/primary.sil && test -f %t/primary.ll && test -f %t/primary.o
|
|
// RUN: test ! -f %t/main.sil && test ! -f %t/main.ll
|
|
// RUN: %FileCheck -input-file %t/primary.sil %s --check-prefix=SIL-CHECK
|
|
// RUN: %FileCheck -input-file %t/primary.ll %s --check-prefix=IR-CHECK
|
|
|
|
// Test switching primary files - same map, different primary file
|
|
// RUN: %target-swift-frontend -emit-object -supplementary-output-file-map %t/multi-map.json -primary-file %/S/../Driver/Inputs/main.swift %/s -o %t/main-primary.o -module-name test
|
|
// RUN: test -f %t/main.sil && test -f %t/main.ll && test -f %t/main-primary.o
|
|
// RUN: %FileCheck -input-file %t/main.sil %s --check-prefix=MAIN-SIL-CHECK
|
|
// RUN: %FileCheck -input-file %t/main.ll %s --check-prefix=MAIN-IR-CHECK
|
|
|
|
// Test partial file maps: SIL-only and IR-only in one test
|
|
// RUN: echo '{"%/s": {"sil": "%/t/partial.sil", "llvm-ir": "%/t/partial.ll"}}' > %t/partial-map.json
|
|
// RUN: %target-swift-frontend -emit-object -supplementary-output-file-map %t/partial-map.json %/s -o %t/partial.o -module-name test
|
|
// RUN: test -f %t/partial.sil && test -f %t/partial.ll && test -f %t/partial.o
|
|
// RUN: %FileCheck -input-file %t/partial.sil %s --check-prefix=SIL-CHECK
|
|
// RUN: %FileCheck -input-file %t/partial.ll %s --check-prefix=IR-CHECK
|
|
|
|
func testFunction() -> Int {
|
|
return 42
|
|
}
|
|
|
|
func runTest() {
|
|
_ = testFunction()
|
|
}
|
|
|
|
// Function expected by main.swift
|
|
func libraryFunction() {}
|
|
|
|
// For module-qualified access
|
|
struct ThisModule {
|
|
static func libraryFunction() {}
|
|
}
|
|
|
|
// SIL-CHECK: sil hidden @$s4test0A8FunctionSiyF : $@convention(thin) () -> Int
|
|
// IR-CHECK: @"$s4test0A8FunctionSiyF"
|
|
|
|
// MAIN-SIL-CHECK: sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32
|
|
// MAIN-IR-CHECK: define{{.*}} i32 @main(
|