|
1 | 1 | // RUN: rm -rf %t
|
2 | 2 | // RUN: mkdir %t
|
3 |
| -// RUN: echo "public var x = Int64()" | %target-swift-frontend -module-name FooBar -emit-module -o %t - |
| 3 | +// RUN: echo "public var x = Int64()" \ |
| 4 | +// RUN: | %target-swift-frontend -module-name FooBar -emit-module -o %t - |
4 | 5 | // RUN: %target-swift-frontend %s -O -I %t -emit-ir -g -o %t.ll
|
5 | 6 | // RUN: FileCheck %s < %t.ll
|
6 | 7 | // RUN: FileCheck %s -check-prefix=TRANSPARENT-CHECK < %t.ll
|
7 | 8 |
|
8 | 9 | // CHECK: define{{( protected)?( signext)?}} i32 @main
|
9 |
| -// CHECK: tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %[[C:.*]], i64 %[[C]]), !dbg ![[MULSCOPE:.*]] |
| 10 | +// CHECK: call {{.*}}noinline{{.*}}, !dbg ![[CALL:.*]] |
10 | 11 | // CHECK-DAG: ![[TOPLEVEL:.*]] = !DIFile(filename: "inlinescopes.swift"
|
11 | 12 |
|
12 | 13 | import FooBar
|
13 | 14 |
|
14 |
| -func markUsed<T>(_ t: T) {} |
| 15 | +func use<T>(_ t: T) {} |
| 16 | + |
| 17 | +@inline(never) |
| 18 | +func noinline(_ x: Int64) -> Int64 { return x } |
| 19 | + |
| 20 | +@_transparent |
| 21 | +func transparent(_ x: Int64) -> Int64 { return noinline(x) } |
| 22 | + |
15 | 23 |
|
16 | 24 | @inline(__always)
|
17 |
| -func square(_ x: Int64) -> Int64 { |
18 |
| -// CHECK-DAG: ![[MULSCOPE]] = !DILocation(line: [[@LINE+2]], column: {{.*}}, scope: ![[MUL:.*]], inlinedAt: ![[INLINED:.*]]) |
19 |
| -// CHECK-DAG: ![[MUL:.*]] = distinct !DILexicalBlock( |
20 |
| - let res = x * x |
21 |
| -// *(Int, Int) is a transparent function and should not show up in the debug info. |
22 |
| -// TRANSPARENT-CHECK-NOT: !DISubprogram(name: "_TFsoi1mFTSiSi_Si" |
23 |
| - return res |
| 25 | +func inlined(_ x: Int64) -> Int64 { |
| 26 | +// CHECK-DAG: ![[CALL]] = !DILocation(line: [[@LINE+2]], column: {{.*}}, scope: ![[SCOPE:.*]], inlinedAt: ![[INLINED:.*]]) |
| 27 | +// CHECK-DAG: ![[SCOPE:.*]] = distinct !DILexicalBlock( |
| 28 | + let result = transparent(x) |
| 29 | +// TRANSPARENT-CHECK-NOT: !DISubprogram(name: "transparent" |
| 30 | + return result |
24 | 31 | }
|
25 |
| -let c = Int64(x) |
26 | 32 | // CHECK-DAG: !DIGlobalVariable(name: "y",{{.*}} file: ![[TOPLEVEL]],{{.*}} line: [[@LINE+1]]
|
27 |
| -let y = square(c) |
28 |
| -markUsed(y) |
| 33 | +let y = inlined(x) |
| 34 | +use(y) |
29 | 35 |
|
30 |
| -// Check if the inlined and removed square function still has the correct linkage name in the debug info. |
31 |
| -// CHECK-DAG: !DISubprogram(name: "square", linkageName: "_TF4main6squareFVs5Int64S0_" |
| 36 | +// Check if the inlined and removed function still has the correct linkage name. |
| 37 | +// CHECK-DAG: !DISubprogram(name: "inlined", linkageName: "_TF4main7inlinedFVs5Int64S0_" |
0 commit comments