Skip to content

Commit 4f38320

Browse files
authored
Merge pull request #3908 from adrian-prantl/27621373
2 parents 1f5301f + 7940718 commit 4f38320

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed

test/DebugInfo/inlinescopes.swift

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
// RUN: rm -rf %t
22
// 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 -
45
// RUN: %target-swift-frontend %s -O -I %t -emit-ir -g -o %t.ll
56
// RUN: FileCheck %s < %t.ll
67
// RUN: FileCheck %s -check-prefix=TRANSPARENT-CHECK < %t.ll
78

89
// 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:.*]]
1011
// CHECK-DAG: ![[TOPLEVEL:.*]] = !DIFile(filename: "inlinescopes.swift"
1112

1213
import FooBar
1314

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+
1523

1624
@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
2431
}
25-
let c = Int64(x)
2632
// 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)
2935

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_"

test/DebugInfo/specialization.swift

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
// RUN: %target-swift-frontend -O %s -disable-llvm-optzns -emit-sil -g -o - | FileCheck %s
22

3-
// CHECK: sil shared [noinline] @_TTSg5SiSis17IntegerArithmetics__
4-
// CHECK-SAME: _TF14specialization3sumuRxs17IntegerArithmeticrFTxx_x
5-
// CHECK-SAME: $@convention(thin) (Int, Int) -> Int {
6-
// CHECK: bb0(%0 : $Int, %1 : $Int):
7-
// CHECK: debug_value %0 : $Int, let, name "i", argno 1
8-
// CHECK: debug_value %1 : $Int, let, name "j", argno 2
9-
3+
// CHECK: sil shared [noinline] @_TTSg5V14specialization7AddableS0_S_5ProtoS____TF14specialization3sumuRxS_5ProtorFTxx_x
4+
// CHECK-SAME: $@convention(thin) (Addable, Addable) -> Addable {
5+
// CHECK: bb0(%0 : $Addable, %1 : $Addable):
6+
// CHECK: debug_value %0 : $Addable, let, name "i", argno 1
7+
// CHECK: debug_value %1 : $Addable, let, name "j", argno 2
8+
9+
public protocol Proto {
10+
static func +(lhs: Self, rhs: Self) -> Self
11+
}
12+
1013
@inline(never)
11-
public func sum<T : IntegerArithmetic>(_ i : T, _ j : T) -> T {
14+
public func sum<T : Proto>(_ i : T, _ j : T) -> T {
1215
let result = i + j
1316
return result
1417
}
1518

16-
public func inc(_ i: inout Int) {
17-
i = sum(i, 1)
19+
func add(_ x: Int, _ y: Int) -> Int { return x+y }
20+
public struct Addable : Proto {
21+
let val : Int
22+
init(_ i : Int) { val = i }
23+
public static func +(lhs: Addable, rhs: Addable) -> Addable {
24+
return Addable(add(lhs.val, rhs.val))
25+
}
26+
}
27+
28+
29+
public func inc(_ i: inout Addable) {
30+
i = sum(i, Addable(1))
1831
}

0 commit comments

Comments
 (0)