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
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+ }
0 commit comments