xref: /llvm-project/llvm/test/MC/WebAssembly/dwarfdump.ll (revision 0e4c7fabd3587c7d95fa4733e4a9001a0bae737f)
1; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
2; RUN: llc -filetype=obj --split-dwarf-file=%t.dwo --split-dwarf-output=%t.dwo %s -o %t.o
3; RUN: llvm-dwarfdump %t.dwo | FileCheck %s -check-prefix=SPLIT
4
5; CHECK: .debug_info contents:
6; CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000006e, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000072)
7
8; CHECK: 0x0000000b: DW_TAG_compile_unit
9; CHECK-NEXT:              DW_AT_producer	("clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)")
10; CHECK-NEXT:              DW_AT_language	(DW_LANG_C99)
11; CHECK-NEXT:              DW_AT_name	("test.c")
12; CHECK-NEXT:              DW_AT_stmt_list	(0x00000000)
13; CHECK-NEXT:              DW_AT_comp_dir	("/usr/local/google/home/sbc/dev/wasm/simple")
14; CHECK-NEXT:              DW_AT_GNU_pubnames	(true)
15; CHECK-NEXT:              DW_AT_low_pc		(0x00000002)
16; CHECK-NEXT:              DW_AT_high_pc	(0x00000004)
17
18; CHECK: 0x00000026:   DW_TAG_variable
19; CHECK-NEXT:                DW_AT_name	("foo")
20; CHECK-NEXT:                DW_AT_type	(0x00000037 "int *")
21; CHECK-NEXT:                DW_AT_external	(true)
22; CHECK-NEXT:                DW_AT_decl_file	("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
23; CHECK-NEXT:                DW_AT_decl_line	(4)
24; CHECK-NEXT:                DW_AT_location	(DW_OP_addr 0x0)
25
26; CHECK: 0x00000037:   DW_TAG_pointer_type
27; CHECK-NEXT:                DW_AT_type	(0x0000003c "int")
28
29; CHECK: 0x0000003c:   DW_TAG_base_type
30; CHECK-NEXT:                DW_AT_name	("int")
31; CHECK-NEXT:                DW_AT_encoding	(DW_ATE_signed)
32; CHECK-NEXT:                DW_AT_byte_size	(0x04)
33
34; CHECK: 0x00000043:   DW_TAG_variable
35; CHECK-NEXT:                DW_AT_name	("ptr2")
36; CHECK-NEXT:                DW_AT_type	(0x00000054 "void (*)()")
37; CHECK-NEXT:                DW_AT_external	(true)
38; CHECK-NEXT:                DW_AT_decl_file	("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
39; CHECK-NEXT:                DW_AT_decl_line	(5)
40; CHECK-NEXT:                DW_AT_location	(DW_OP_addr 0x4)
41
42; CHECK: 0x00000054:   DW_TAG_pointer_type
43; CHECK-NEXT:                DW_AT_type	(0x00000059 "void ()")
44
45; CHECK: 0x00000059:   DW_TAG_subroutine_type
46; CHECK-NEXT:                DW_AT_prototyped	(true)
47
48; CHECK: 0x0000005a:   DW_TAG_subprogram
49; CHECK-NEXT:                DW_AT_low_pc	(0x00000002)
50; CHECK-NEXT:                DW_AT_high_pc	(0x00000004)
51; CHECK-NEXT:                DW_AT_frame_base	(DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
52; CHECK-NEXT:                DW_AT_name	("f2")
53; CHECK-NEXT:                DW_AT_decl_file	("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
54; CHECK-NEXT:                DW_AT_decl_line	(2)
55; CHECK-NEXT:                DW_AT_prototyped	(true)
56; CHECK-NEXT:                DW_AT_external		(true)
57
58; CHECK: 0x00000071:   NULL
59
60
61; SPLIT:      .debug_info.dwo contents:
62; SPLIT-NEXT: 0x00000000: Compile Unit: length = 0x0000004c, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000050)
63
64; SPLIT:      0x0000000b: DW_TAG_compile_unit
65; SPLIT-NEXT:               DW_AT_producer    ("clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)")
66; SPLIT-NEXT:               DW_AT_language    (DW_LANG_C99)
67; SPLIT-NEXT:               DW_AT_name        ("test.c")
68; SPLIT-NEXT:               DW_AT_GNU_dwo_name        ("{{.*}}dwarfdump.ll.tmp.dwo")
69; SPLIT-NEXT:               DW_AT_GNU_dwo_id  ({{.*}})
70
71; SPLIT:      0x00000019:   DW_TAG_variable
72; SPLIT-NEXT:                 DW_AT_name      ("foo")
73; SPLIT-NEXT:                 DW_AT_type      (0x00000024 "int *")
74; SPLIT-NEXT:                 DW_AT_external  (true)
75; SPLIT-NEXT:                 DW_AT_decl_file (0x01)
76; SPLIT-NEXT:                 DW_AT_decl_line (4)
77; SPLIT-NEXT:                 DW_AT_location  (DW_OP_GNU_addr_index 0x0)
78
79; SPLIT:      0x00000024:   DW_TAG_pointer_type
80; SPLIT-NEXT:                 DW_AT_type      (0x00000029 "int")
81
82; SPLIT:      0x00000029:   DW_TAG_base_type
83; SPLIT-NEXT:                 DW_AT_name      ("int")
84; SPLIT-NEXT:                 DW_AT_encoding  (DW_ATE_signed)
85; SPLIT-NEXT:                 DW_AT_byte_size (0x04)
86
87; SPLIT:      0x0000002d:   DW_TAG_variable
88; SPLIT-NEXT:                 DW_AT_name      ("ptr2")
89; SPLIT-NEXT:                 DW_AT_type      (0x00000038 "void (*)()")
90; SPLIT-NEXT:                 DW_AT_external  (true)
91; SPLIT-NEXT:                 DW_AT_decl_file (0x01)
92; SPLIT-NEXT:                 DW_AT_decl_line (5)
93; SPLIT-NEXT:                 DW_AT_location  (DW_OP_GNU_addr_index 0x1)
94
95; SPLIT:      0x00000038:   DW_TAG_pointer_type
96; SPLIT-NEXT:                 DW_AT_type      (0x0000003d "void ()")
97
98; SPLIT:      0x0000003d:   DW_TAG_subroutine_type
99; SPLIT-NEXT:                 DW_AT_prototyped        (true)
100
101; SPLIT:      0x0000003e:   DW_TAG_subprogram
102; SPLIT-NEXT:                 DW_AT_low_pc    (indexed (00000002) address = <unresolved>)
103; SPLIT-NEXT:                 DW_AT_high_pc   (0x00000002)
104; SPLIT-NEXT:                 DW_AT_frame_base        (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
105; SPLIT-NEXT:                 DW_AT_name      ("f2")
106; SPLIT-NEXT:                 DW_AT_decl_file (0x01)
107; SPLIT-NEXT:                 DW_AT_decl_line (2)
108; SPLIT-NEXT:                 DW_AT_prototyped        (true)
109; SPLIT-NEXT:                 DW_AT_external  (true)
110
111; SPLIT:      0x0000004f:   NULL
112
113
114target triple = "wasm32-unknown-unknown"
115
116source_filename = "test.c"
117
118@myextern = external global i32, align 4
119@foo = hidden global ptr @myextern, align 4, !dbg !0
120@ptr2 = hidden global ptr @f2, align 4, !dbg !6
121
122; Function Attrs: noinline nounwind optnone
123define hidden void @f2() #0 !dbg !17 {
124entry:
125  ret void, !dbg !18
126}
127
128attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
129
130!llvm.dbg.cu = !{!2}
131!llvm.module.flags = !{!13, !14, !15}
132!llvm.ident = !{!16}
133
134!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
135!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
136!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
137!3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
138!4 = !{}
139!5 = !{!0, !6}
140!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
141!7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
142!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
143!9 = !DISubroutineType(types: !10)
144!10 = !{null}
145!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
146!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
147!13 = !{i32 2, !"Dwarf Version", i32 4}
148!14 = !{i32 2, !"Debug Info Version", i32 3}
149!15 = !{i32 1, !"wchar_size", i32 4}
150!16 = !{!"clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)"}
151!17 = distinct !DISubprogram(name: "f2", scope: !3, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
152!18 = !DILocation(line: 2, column: 16, scope: !17)
153