Skip to content

Commit 1b6ad50

Browse files
committed
Make this testcase more robust against dead code elimination.
1 parent 41e4e9b commit 1b6ad50

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/DebugInfo/inlinedAt.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@
22
// RUN: | FileCheck %s --check-prefix=CHECK-SIL
33
// RUN: %target-swift-frontend %s -O -I %t -emit-ir -g -o - | FileCheck %s
44

5+
public var glob : Int = 0
6+
@inline(never) public func hold(_ n : Int) { glob = n }
7+
58
#sourceLocation(file: "abc.swift", line: 100)
69
@inline(__always)
7-
func h(_ k : Int) -> Int { // 101
8-
return k // 102
10+
func h(_ k : Int) -> Int { // 101
11+
hold(k) // 102
12+
return k // 103
913
}
1014

1115
#sourceLocation(file: "abc.swift", line: 200)
1216
@inline(__always)
13-
func g(_ j : Int) -> Int { // 201
14-
return h(j) // 202
17+
func g(_ j : Int) -> Int { // 201
18+
hold(j) // 202
19+
return h(j) // 203
1520
}
1621

1722
#sourceLocation(file: "abc.swift", line: 301)
1823
public func f(_ i : Int) -> Int { // 301
19-
return g(i) // 302
24+
return g(i) // 302
2025
}
2126

2227
// CHECK-SIL: sil {{.*}}@_TF9inlinedAt1fFSiSi :
2328
// CHECK-SIL-NOT: return
2429
// CHECK-SIL: debug_value %0 : $Int, let, name "k", argno 1
2530
// CHECK-SIL-SAME: line:101:10:in_prologue
26-
// CHECK-SIL-SAME: perf_inlined_at line:202:10
31+
// CHECK-SIL-SAME: perf_inlined_at line:203:10
2732
// CHECK-SIL-SAME: perf_inlined_at line:302:10
2833

2934
// CHECK: define {{.*}}@_TF9inlinedAt1fFSiSi
@@ -40,9 +45,9 @@ public func f(_ i : Int) -> Int { // 301
4045
// CHECK-SAME: scope: ![[F_SCOPE:.*]])
4146
// CHECK: ![[F_SCOPE]] = distinct !DILexicalBlock(scope: ![[F]],
4247
// CHECK-SAME: line: 301, column: 33)
48+
// CHECK: ![[G_SCOPE:.*]] = distinct !DILexicalBlock(scope: ![[G]],
49+
// CHECK-SAME: line: 201, column: 26)
4350
// CHECK: ![[L1]] = !DILocation(line: 101, column: 8, scope: ![[H]],
4451
// CHECK-SAME: inlinedAt: ![[L2:.*]])
45-
// CHECK: ![[L2]] = !DILocation(line: 202, column: 13, scope: ![[G_SCOPE:.*]],
52+
// CHECK: ![[L2]] = !DILocation(line: 203, column: 13, scope: ![[G_SCOPE]],
4653
// CHECK-SAME: inlinedAt: ![[L3]])
47-
// CHECK: ![[G_SCOPE]] = distinct !DILexicalBlock(scope: ![[G]],
48-
// CHECK-SAME: line: 201, column: 26)

0 commit comments

Comments
 (0)