xref: /llvm-project/llvm/test/DebugInfo/X86/convert-debugloc.ll (revision 0e4c7fabd3587c7d95fa4733e4a9001a0bae737f)
1; RUN: llc -mtriple=x86_64 -dwarf-version=4 -filetype=obj -O0 < %s | llvm-dwarfdump - \
2; RUN:   | FileCheck %s --check-prefix=NOCONV "--implicit-check-not={{DW_TAG|NULL}}"
3
4; Test lldb default: OP_convert is unsupported when using MachO
5; RUN: llc -mtriple=x86_64-apple-darwin -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb | llvm-dwarfdump - \
6; RUN:   | FileCheck %s --check-prefix=CONV "--implicit-check-not={{DW_TAG|NULL}}"
7; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb | llvm-dwarfdump - \
8; RUN:   | FileCheck %s --check-prefix=NOCONV "--implicit-check-not={{DW_TAG|NULL}}"
9
10; Test gdb default: OP_convert is only disabled in split DWARF
11; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  | llvm-dwarfdump - \
12; RUN:   | FileCheck %s --check-prefix=CONV "--implicit-check-not={{DW_TAG|NULL}}"
13; RUN: llc -mtriple=x86_64-pc-linux-gnu  -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb   -split-dwarf-file=baz.dwo | llvm-dwarfdump - \
14; RUN:   | FileCheck %s --check-prefix=NOCONV --check-prefix=SPLIT "--implicit-check-not={{DW_TAG|NULL}}"
15
16; Test the ability to override the platform default in either direction
17; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  -dwarf-op-convert=Disable | llvm-dwarfdump - \
18; RUN:   | FileCheck %s --check-prefix=NOCONV "--implicit-check-not={{DW_TAG|NULL}}"
19; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb -dwarf-op-convert=Enable | llvm-dwarfdump - \
20; RUN:   | FileCheck %s --check-prefix=CONV "--implicit-check-not={{DW_TAG|NULL}}"
21
22; Test DW_OP_convert + Split DWARF
23; RUN: llc -mtriple=x86_64-pc-linux-gnu -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=lldb -dwarf-op-convert=Enable -split-dwarf-file=baz.dwo | llvm-dwarfdump - \
24; RUN:   | FileCheck %s --check-prefix=CONV --check-prefix=SPLITCONV --check-prefix=SPLIT "--implicit-check-not={{DW_TAG|NULL}}"
25
26; RUN: llc -mtriple=x86_64 -dwarf-version=5 -filetype=obj -O0 < %s -debugger-tune=gdb  | llvm-dwarfdump -v -debug-info - \
27; RUN:   | FileCheck %s --check-prefix=VERBOSE --check-prefix=CONV "--implicit-check-not={{DW_TAG|NULL}}"
28
29
30;; NB: This checks that the type reference in DW_OP_convert participates in the
31;; DWO hash.
32; SPLITCONV: Compile Unit:{{.*}} DWO_id = 0xbf4ac610d9ea282c
33; SPLIT: DW_TAG_skeleton_unit
34
35; CONV: DW_TAG_compile_unit
36; CONV:[[SIG8:.*]]:   DW_TAG_base_type
37; CONV-NEXT:DW_AT_name {{.*}}"DW_ATE_signed_8")
38; CONV-NEXT:DW_AT_encoding {{.*}}DW_ATE_signed)
39; CONV-NEXT:DW_AT_byte_size {{.*}}0x01)
40; CONV-NOT: DW_AT
41; CONV:[[SIG32:.*]]:   DW_TAG_base_type
42; CONV-NEXT:DW_AT_name {{.*}}"DW_ATE_signed_32")
43; CONV-NEXT:DW_AT_encoding {{.*}}DW_ATE_signed)
44; CONV-NEXT:DW_AT_byte_size {{.*}}0x04)
45; CONV-NOT: DW_AT
46; CONV:   DW_TAG_base_type
47; CONV:   DW_TAG_base_type
48; CONV:   DW_TAG_subprogram
49; CONV:     DW_TAG_formal_parameter
50; CONV:     DW_TAG_variable
51; CONV:     DW_AT_location {{.*}}DW_OP_constu 0x20, DW_OP_lit0, DW_OP_plus, DW_OP_convert (
52; VERBOSE-SAME: [[SIG8]] ->
53; CONV-SAME: [[SIG8]]) "DW_ATE_signed_8", DW_OP_convert (
54; VERBOSE-SAME: [[SIG32]] ->
55; CONV-SAME: [[SIG32]]) "DW_ATE_signed_32", DW_OP_stack_value)
56; CONV:       DW_AT_name {{.*}}"y")
57; CONV:     DW_TAG_variable
58; CONV:     NULL
59; CONV:   DW_TAG_base_type
60; CONV:     DW_AT_name {{.*}}"signed char")
61; CONV:   DW_TAG_base_type
62; CONV:     DW_AT_name {{.*}}"int")
63; CONV:   DW_TAG_base_type
64; CONV:     DW_AT_name {{.*}}"unsigned long long")
65; CONV:   NULL
66
67; NOCONV: DW_TAG_compile_unit
68; NOCONV:   DW_TAG_subprogram
69; NOCONV:     DW_TAG_formal_parameter
70; NOCONV:     DW_TAG_variable
71; NOCONV:       DW_AT_location (
72; NOCONV:         {{.*}}, DW_OP_dup, DW_OP_constu 0x7, DW_OP_shr, DW_OP_lit0, DW_OP_not, DW_OP_mul, DW_OP_constu 0x8, DW_OP_shl, DW_OP_or, DW_OP_stack_value)
73; NOCONV:       DW_AT_name ("y")
74; NOCONV:     DW_TAG_variable
75; NOCONV:       DW_AT_location (
76; NOCONV:         DW_OP_constu 0x40, DW_OP_lit0, DW_OP_plus, DW_OP_lit1, DW_OP_constu 0x40, DW_OP_shl, DW_OP_lit1, DW_OP_minus, DW_OP_and, DW_OP_stack_value)
77; NOCONV:       DW_AT_name ("z")
78; NOCONV:     NULL
79; NOCONV:   DW_TAG_base_type
80; NOCONV:     DW_AT_name ("signed char")
81; NOCONV:   DW_TAG_base_type
82; NOCONV:     DW_AT_name ("int")
83; NOCONV:   DW_TAG_base_type
84; NOCONV:     DW_AT_name ("unsigned long long")
85; NOCONV:   NULL
86
87
88; Function Attrs: noinline nounwind uwtable
89define dso_local signext i8 @foo(i8 signext %x) !dbg !7 {
90entry:
91  call void @llvm.dbg.value(metadata i8 %x, metadata !11, metadata !DIExpression()), !dbg !12
92;; This test depends on "convert" surviving all the way to the final object.
93;; So, insert something before DW_OP_LLVM_convert that the expression folder
94;; will not attempt to eliminate.  At the moment, only "convert" ops are folded.
95;; If you have to change the expression, the expected DWO_id also changes.
96  call void @llvm.dbg.value(metadata i8 32, metadata !13, metadata !DIExpression(DW_OP_lit0, DW_OP_plus, DW_OP_LLVM_convert, 8, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_stack_value)), !dbg !15
97  call void @llvm.dbg.value(metadata i8 64, metadata !17, metadata !DIExpression(DW_OP_lit0, DW_OP_plus, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 128, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !15
98  ret i8 %x, !dbg !16
99}
100
101; Function Attrs: nounwind readnone speculatable
102declare void @llvm.dbg.declare(metadata, metadata, metadata)
103
104; Function Attrs: nounwind readnone speculatable
105declare void @llvm.dbg.value(metadata, metadata, metadata)
106
107!llvm.dbg.cu = !{!0}
108!llvm.module.flags = !{!3, !4, !5}
109!llvm.ident = !{!6}
110
111!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (trunk 353791) (llvm/trunk 353801)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
112!1 = !DIFile(filename: "dbg.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "2a034da6937f5b9cf6dd2d89127f57fd")
113!2 = !{}
114!3 = !{i32 2, !"Dwarf Version", i32 5}
115!4 = !{i32 2, !"Debug Info Version", i32 3}
116!5 = !{i32 1, !"wchar_size", i32 4}
117!6 = !{!"clang version 9.0.0 (trunk 353791) (llvm/trunk 353801)"}
118!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
119!8 = !DISubroutineType(types: !9)
120!9 = !{!10, !10}
121!10 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
122!11 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 1, type: !10)
123!12 = !DILocation(line: 1, column: 29, scope: !7)
124!13 = !DILocalVariable(name: "y", scope: !7, file: !1, line: 3, type: !14)
125!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
126!15 = !DILocation(line: 3, column: 14, scope: !7)
127!16 = !DILocation(line: 4, column: 3, scope: !7)
128!17 = !DILocalVariable(name: "z", scope: !7, file: !1, line: 3, type: !18)
129!18 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)
130