Skip to content

Commit a5db086

Browse files
authored
Merge pull request #15195 from slavapestov/test-19978257
Add test that we correctly serialize SIL functions whose bodies are emitted by Clang
2 parents 04ea4cc + ed40787 commit a5db086

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@_inlineable public func testit(x: Int32) -> Int32 {
2+
return c_inline_func(x)
3+
}

test/ClangImporter/static_inline.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
// Check if SIL printing+parsing of a clang imported function works.
44

5-
// RUN: %target-swift-frontend -parse-as-library -module-name=test -emit-sil %s -import-objc-header %S/Inputs/static_inline.h -o %t/test.sil
6-
// RUN: %FileCheck < %t/test.sil %s
7-
// RUN: %target-swift-frontend -parse-as-library -module-name=test -O -emit-ir %t/test.sil -import-objc-header %S/Inputs/static_inline.h | %FileCheck --check-prefix=CHECK-IR %s
5+
// RUN: %target-swift-frontend -parse-as-library -module-name=static_inline -emit-sil %S/Inputs/static_inline.swift -import-objc-header %S/Inputs/static_inline.h -o %t/static_inline.sil
6+
// RUN: %FileCheck < %t/static_inline.sil %s
7+
// RUN: %target-swift-frontend -parse-as-library -module-name=static_inline -O -emit-ir %t/static_inline.sil -import-objc-header %S/Inputs/static_inline.h | %FileCheck --check-prefix=CHECK-IR %s
88

99
// CHECK: sil shared [serializable] [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32
1010

11-
// CHECK-IR-LABEL: define{{.*}} i32 @"$S4test6testit1xs5Int32VAE_tF"(i32)
11+
// CHECK-IR-LABEL: define{{.*}} i32 @"$S13static_inline6testit1xs5Int32VAE_tF"(i32)
1212
// CHECK-IR: = add {{.*}}, 27
1313
// CHECK-IR: ret
1414

15-
public func testit(x: Int32) -> Int32 {
16-
return c_inline_func(x)
15+
import static_inline
16+
17+
public func mytest(x: Int32) -> Int32 {
18+
return testit(x: x)
1719
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// Try serialization of clang-generated functions.
4+
5+
// RUN: %target-swift-frontend -parse-as-library -module-name=static_inline -emit-module %S/Inputs/static_inline.swift -import-objc-header %S/Inputs/static_inline.h -o %t/static_inline.swiftmodule
6+
// RUN: %target-swift-frontend -module-name test -O -emit-sil %s -I %t | %FileCheck %s
7+
// RUN: %target-swift-frontend -module-name test -O -emit-ir %s -I %t | %FileCheck --check-prefix=CHECK-IR %s
8+
9+
// CHECK: sil shared_external [clang c_inline_func] @c_inline_func : $@convention(c) (Int32) -> Int32
10+
11+
// CHECK-IR-LABEL: define{{.*}} i32 @"$S4test6mytest1xs5Int32VAE_tF"(i32)
12+
// CHECK-IR: = add {{.*}}, 27
13+
// CHECK-IR: ret
14+
15+
import static_inline
16+
17+
public func mytest(x: Int32) -> Int32 {
18+
return testit(x: x)
19+
}

0 commit comments

Comments
 (0)