Skip to content

Commit 7c32e00

Browse files
Merge pull request #84234 from charles-zablit/charles-zablit/windows/fix-debuginfo-basic-test-failures
[windows] create a Windows specific Debug/basic.swift test
2 parents 6e960d5 + 68b3b53 commit 7c32e00

File tree

3 files changed

+106
-83
lines changed

3 files changed

+106
-83
lines changed

test/DebugInfo/advanced.swift

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// A (no longer) basic test for debug info.
2+
// --------------------------------------------------------------------
3+
// Verify that we don't emit any type info with -gline-tables-only.
4+
// RUN: %target-swift-frontend %s -emit-ir -gline-tables-only -o - \
5+
// RUN: | %FileCheck %s --check-prefix CHECK-LINETABLES
6+
// CHECK: !dbg
7+
// CHECK-LINETABLES-NOT: DI{{.*}}Variable
8+
// CHECK-LINETABLES-NOT: DW_TAG_structure_type
9+
// CHECK-LINETABLES-NOT: DIBasicType
10+
// --------------------------------------------------------------------
11+
// Now check that we do generate line+scope info with -g.
12+
// RUN: %target-swift-frontend %/s -emit-ir -g -o - \
13+
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
14+
// --------------------------------------------------------------------
15+
// Currently -gdwarf-types should give the same results as -g.
16+
// RUN: %target-swift-frontend %/s -emit-ir -gdwarf-types -o - \
17+
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
18+
// --------------------------------------------------------------------
19+
// Verify that -g -debug-info-format=dwarf gives the same results as -g.
20+
// RUN: %target-swift-frontend %/s -emit-ir -g -debug-info-format=dwarf -o - \
21+
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
22+
// --------------------------------------------------------------------
23+
// RUN: %target-swift-frontend %/s -emit-ir -g -debug-info-format=codeview -o - \
24+
// RUN: | %FileCheck %s --check-prefixes CHECK,CV-CHECK
25+
// --------------------------------------------------------------------
26+
//
27+
// CHECK: foo
28+
// CHECK-DAG: ret{{.*}}, !dbg ![[RET:[0-9]+]]
29+
// CHECK-DAG: ![[FOO:[0-9]+]] = distinct !DISubprogram(name: "foo",{{.*}} line: [[@LINE+2]],{{.*}} type: ![[FOOTYPE:[0-9]+]]
30+
public
31+
func foo(_ a: Int64, _ b: Int64) -> Int64 {
32+
var a = a
33+
var b = b
34+
// CHECK-DAG: ![[ALOC:.*]] = !DILocation(line: [[@LINE-3]],{{.*}} scope: ![[FOO]])
35+
// Check that a is the first and b is the second argument.
36+
// CHECK-DAG: store i64 %0, ptr [[AADDR:.*]], align
37+
// CHECK-DAG: store i64 %1, ptr [[BADDR:.*]], align
38+
// CHECK-DAG: [[AVAL:%.*]] = getelementptr inbounds {{.*}}, [[AMEM:.*]], i32 0, i32 0
39+
// CHECK-DAG: [[BVAL:%.*]] = getelementptr inbounds {{.*}}, [[BMEM:.*]], i32 0, i32 0
40+
// CHECK-DAG: #dbg_declare(ptr [[AADDR]], ![[AARG:.*]], !DIExpression(), ![[ALOC]]
41+
// CHECK-DAG: #dbg_declare(ptr [[BADDR]], ![[BARG:.*]], !DIExpression()
42+
// CHECK-DAG: ![[AARG]] = !DILocalVariable(name: "a", arg: 1
43+
// CHECK-DAG: ![[BARG]] = !DILocalVariable(name: "b", arg: 2
44+
if b != 0 {
45+
// CHECK-DAG: !DILexicalBlock({{.*}} line: [[@LINE-1]]
46+
// Transparent inlined multiply:
47+
// CHECK-DAG: smul{{.*}}, !dbg ![[MUL:[0-9]+]]
48+
// CHECK-DAG: [[MUL]] = !DILocation(line: [[@LINE+1]],
49+
return a*b
50+
} else {
51+
// CHECK-DAG: ![[PARENT:[0-9]+]] = distinct !DILexicalBlock({{.*}} line: [[@LINE-1]]
52+
// CHECK-DAG: ![[VARSCOPE:[0-9]+]] = distinct !DILexicalBlock({{.*}} line: [[@LINE+1]]
53+
var c: Int64 = 42
54+
// CHECK-DAG: ![[CONDITION:[0-9]+]] = distinct !DILexicalBlock(scope: ![[VARSCOPE]], {{.*}}, line: [[@LINE+1]]
55+
if a == 0 {
56+
// CHECK-DAG: !DILexicalBlock(scope: ![[CONDITION]], {{.*}}, line: [[@LINE-1]]
57+
// What about a nested scope?
58+
return 0
59+
}
60+
return c
61+
}
62+
}
63+
64+
// CHECK-DAG: ![[MAINFILE:[0-9]+]] = !DIFile(filename: "{{.*}}DebugInfo/advanced.swift", directory: "{{.*}}")
65+
// CHECK-DAG: !DICompileUnit(language: DW_LANG_Swift, file: ![[MAINFILE]],{{.*}} producer: "{{.*}}Swift version{{.*}},{{.*}}
66+
// CHECK-DAG: !DISubprogram(name: "main", {{.*}}file: ![[MAINFILE]],
67+
68+
// Function type for foo.
69+
// CHECK-DAG: ![[FOOTYPE]] = !DISubroutineType(types: ![[PARAMTYPES:[0-9]+]])
70+
// CHECK-DAG: ![[INT64:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Int64", {{.*}}, identifier: "$ss5Int64VD")
71+
// CHECK-DAG: ![[PARAMTYPES]] = !{![[INT64]], ![[INT64]], ![[INT64]]}
72+
// Import of the main module with the implicit name.
73+
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[MAINFILE]], entity: ![[MAINMODULE:[0-9]+]], file: ![[MAINFILE]])
74+
// CHECK-DAG: ![[MAINMODULE]] = !DIModule({{.*}}, name: "advanced"
75+
76+
// DWARF Version
77+
// DWARF-CHECK-DAG: i32 7, !"Dwarf Version", i32 4}
78+
// CV-CHECK-DAG: i32 2, !"CodeView", i32 1}
79+
80+
// Debug Info Version
81+
// CHECK-DAG: i32 2, !"Debug Info Version", i32

test/DebugInfo/basic.swift

Lines changed: 8 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// A (no longer) basic test for debug info.
2-
// XFAIL: OS=windows-msvc
1+
// A basic test for debug info.
2+
// UNSUPPORTED: OS=windows-msvc
33
// --------------------------------------------------------------------
4-
// Verify that we don't emit any debug info by default.
4+
// Verify that we don't emit any debug info by default. This test has a
5+
// specific Windows implementation in debug_basic_windows.swift.
56
// RUN: %target-swift-frontend %s -emit-ir -o - \
67
// RUN: | %FileCheck %s --check-prefix NDEBUG
78
// NDEBUG: source_filename
@@ -11,83 +12,7 @@
1112
// Verify that we don't emit any debug info with -gnone.
1213
// RUN: %target-swift-frontend %s -emit-ir -gnone -o - \
1314
// RUN: | %FileCheck %s --check-prefix NDEBUG
14-
// --------------------------------------------------------------------
15-
// Verify that we don't emit any type info with -gline-tables-only.
16-
// RUN: %target-swift-frontend %s -emit-ir -gline-tables-only -o - \
17-
// RUN: | %FileCheck %s --check-prefix CHECK-LINETABLES
18-
// CHECK: !dbg
19-
// CHECK-LINETABLES-NOT: DI{{.*}}Variable
20-
// CHECK-LINETABLES-NOT: DW_TAG_structure_type
21-
// CHECK-LINETABLES-NOT: DIBasicType
22-
// --------------------------------------------------------------------
23-
// Now check that we do generate line+scope info with -g.
24-
// RUN: %target-swift-frontend %/s -emit-ir -g -o - \
25-
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
26-
// --------------------------------------------------------------------
27-
// Currently -gdwarf-types should give the same results as -g.
28-
// RUN: %target-swift-frontend %/s -emit-ir -gdwarf-types -o - \
29-
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
30-
// --------------------------------------------------------------------
31-
// Verify that -g -debug-info-format=dwarf gives the same results as -g.
32-
// RUN: %target-swift-frontend %/s -emit-ir -g -debug-info-format=dwarf -o - \
33-
// RUN: | %FileCheck %s --check-prefixes CHECK,DWARF-CHECK
34-
// --------------------------------------------------------------------
35-
// RUN: %target-swift-frontend %/s -emit-ir -g -debug-info-format=codeview -o - \
36-
// RUN: | %FileCheck %s --check-prefixes CHECK,CV-CHECK
37-
// --------------------------------------------------------------------
38-
//
39-
// CHECK: foo
40-
// CHECK-DAG: ret{{.*}}, !dbg ![[RET:[0-9]+]]
41-
// CHECK-DAG: ![[FOO:[0-9]+]] = distinct !DISubprogram(name: "foo",{{.*}} line: [[@LINE+2]],{{.*}} type: ![[FOOTYPE:[0-9]+]]
42-
public
43-
func foo(_ a: Int64, _ b: Int64) -> Int64 {
44-
var a = a
45-
var b = b
46-
// CHECK-DAG: ![[ALOC:.*]] = !DILocation(line: [[@LINE-3]],{{.*}} scope: ![[FOO]])
47-
// Check that a is the first and b is the second argument.
48-
// CHECK-DAG: store i64 %0, ptr [[AADDR:.*]], align
49-
// CHECK-DAG: store i64 %1, ptr [[BADDR:.*]], align
50-
// CHECK-DAG: [[AVAL:%.*]] = getelementptr inbounds {{.*}}, [[AMEM:.*]], i32 0, i32 0
51-
// CHECK-DAG: [[BVAL:%.*]] = getelementptr inbounds {{.*}}, [[BMEM:.*]], i32 0, i32 0
52-
// CHECK-DAG: #dbg_declare(ptr [[AADDR]], ![[AARG:.*]], !DIExpression(), ![[ALOC]]
53-
// CHECK-DAG: #dbg_declare(ptr [[BADDR]], ![[BARG:.*]], !DIExpression()
54-
// CHECK-DAG: ![[AARG]] = !DILocalVariable(name: "a", arg: 1
55-
// CHECK-DAG: ![[BARG]] = !DILocalVariable(name: "b", arg: 2
56-
if b != 0 {
57-
// CHECK-DAG: !DILexicalBlock({{.*}} line: [[@LINE-1]]
58-
// Transparent inlined multiply:
59-
// CHECK-DAG: smul{{.*}}, !dbg ![[MUL:[0-9]+]]
60-
// CHECK-DAG: [[MUL]] = !DILocation(line: [[@LINE+1]],
61-
return a*b
62-
} else {
63-
// CHECK-DAG: ![[PARENT:[0-9]+]] = distinct !DILexicalBlock({{.*}} line: [[@LINE-1]]
64-
// CHECK-DAG: ![[VARSCOPE:[0-9]+]] = distinct !DILexicalBlock({{.*}} line: [[@LINE+1]]
65-
var c: Int64 = 42
66-
// CHECK-DAG: ![[CONDITION:[0-9]+]] = distinct !DILexicalBlock(scope: ![[VARSCOPE]], {{.*}}, line: [[@LINE+1]]
67-
if a == 0 {
68-
// CHECK-DAG: !DILexicalBlock(scope: ![[CONDITION]], {{.*}}, line: [[@LINE-1]]
69-
// What about a nested scope?
70-
return 0
71-
}
72-
return c
73-
}
74-
}
75-
76-
// CHECK-DAG: ![[MAINFILE:[0-9]+]] = !DIFile(filename: "{{.*}}DebugInfo/basic.swift", directory: "{{.*}}")
77-
// CHECK-DAG: !DICompileUnit(language: DW_LANG_Swift, file: ![[MAINFILE]],{{.*}} producer: "{{.*}}Swift version{{.*}},{{.*}}
78-
// CHECK-DAG: !DISubprogram(name: "main", {{.*}}file: ![[MAINFILE]],
79-
80-
// Function type for foo.
81-
// CHECK-DAG: ![[FOOTYPE]] = !DISubroutineType(types: ![[PARAMTYPES:[0-9]+]])
82-
// CHECK-DAG: ![[INT64:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Int64", {{.*}}, identifier: "$ss5Int64VD")
83-
// CHECK-DAG: ![[PARAMTYPES]] = !{![[INT64]], ![[INT64]], ![[INT64]]}
84-
// Import of the main module with the implicit name.
85-
// CHECK-DAG: !DIImportedEntity(tag: DW_TAG_imported_module, scope: ![[MAINFILE]], entity: ![[MAINMODULE:[0-9]+]], file: ![[MAINFILE]])
86-
// CHECK-DAG: ![[MAINMODULE]] = !DIModule({{.*}}, name: "basic"
87-
88-
// DWARF Version
89-
// DWARF-CHECK-DAG: i32 7, !"Dwarf Version", i32 4}
90-
// CV-CHECK-DAG: i32 2, !"CodeView", i32 1}
91-
92-
// Debug Info Version
93-
// CHECK-DAG: i32 2, !"Debug Info Version", i32
15+
public func foo() -> Int {
16+
let bar = 1
17+
return bar
18+
}

test/DebugInfo/basic_windows.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// A basic test for debug info.
2+
// REQUIRES: OS=windows-msvc
3+
// --------------------------------------------------------------------
4+
// Verify that, by default, we exactly emit 1 DICompileUnit entry without dwoId.
5+
// On Windows, we always emit minimal DebugInfo to match MSVC's behavior:
6+
// See https://github.com/llvm/llvm-project/pull/142970 for more details.
7+
// RUN: %target-swift-frontend %s -emit-ir -o - \
8+
// RUN: | %FileCheck %s --check-prefix NDEBUG
9+
// NDEBUG: source_filename
10+
// NDEBUG: !DICompileUnit(
11+
// NDEBUG-NOT: dwoId:
12+
// NDEBUG-SAME: )
13+
// NDEBUG-NOT: !DICompileUnit(
14+
public func foo() -> Int {
15+
let bar = 1
16+
return bar
17+
}

0 commit comments

Comments
 (0)