xref: /llvm-project/llvm/test/DebugInfo/X86/convert-linked.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: llc -mtriple=x86_64 -filetype=obj -O0 < %s | llvm-dwarfdump - | FileCheck %s
2; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64 -filetype=obj -O0 < %s | llvm-dwarfdump - | FileCheck %s
3
4; CHECK: DW_TAG_compile_unit
5; CHECK: [[CU0BT0:0x[0-9a-f]+]]: DW_TAG_base_type
6; CHECK-NEXT: DW_ATE_signed_8
7; CHECK: [[CU0BT1:0x[0-9a-f]+]]: DW_TAG_base_type
8; CHECK-NEXT: DW_ATE_signed_32
9; CHECK: DW_TAG_variable
10; CHECK: DW_OP_convert ([[CU0BT0]]) "DW_ATE_signed_8", DW_OP_convert ([[CU0BT1]]) "DW_ATE_signed_32"
11
12; CHECK: DW_TAG_compile_unit
13; CHECK: [[CU1BT0:0x[0-9a-f]+]]: DW_TAG_base_type
14; CHECK-NEXT: DW_ATE_signed_8
15; CHECK: [[CU1BT1:0x[0-9a-f]+]]: DW_TAG_base_type
16; CHECK-NEXT: DW_ATE_signed_16
17; CHECK: DW_TAG_variable
18; CHECK: DW_OP_convert ([[CU1BT0]]) "DW_ATE_signed_8", DW_OP_convert ([[CU1BT1]]) "DW_ATE_signed_16"
19
20define dso_local signext i8 @foo(i8 signext %x) !dbg !9 {
21entry:
22  call void @llvm.dbg.value(metadata i8 %x, metadata !13, metadata !DIExpression()), !dbg !14
23;; This test depends on "convert" surviving all the way to the final object.
24;; So, insert something before DW_OP_LLVM_convert that the expression folder
25;; will not attempt to eliminate.  At the moment, only "convert" ops are folded.
26  call void @llvm.dbg.value(metadata i8 32, metadata !15, 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 !17
27  ret i8 %x, !dbg !18
28}
29
30define dso_local signext i8 @bar(i8 signext %x) !dbg !19 {
31entry:
32  call void @llvm.dbg.value(metadata i8 %x, metadata !20, metadata !DIExpression()), !dbg !21
33;; This test depends on "convert" surviving all the way to the final object.
34;; So, insert something before DW_OP_LLVM_convert that the expression folder
35;; will not attempt to eliminate.  At the moment, only "convert" ops are folded.
36  call void @llvm.dbg.value(metadata i8 32, metadata !22, metadata !DIExpression(DW_OP_lit0, DW_OP_plus, DW_OP_LLVM_convert, 8, DW_ATE_signed, DW_OP_LLVM_convert, 16, DW_ATE_signed, DW_OP_stack_value)), !dbg !24
37  ret i8 %x, !dbg !25
38}
39
40; Function Attrs: nounwind readnone speculatable
41declare void @llvm.dbg.value(metadata, metadata, metadata) #1
42
43attributes #1 = { nounwind readnone speculatable }
44
45!llvm.dbg.cu = !{!0, !3}
46!llvm.ident = !{!5, !5}
47!llvm.module.flags = !{!6, !7, !8}
48
49!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
50!1 = !DIFile(filename: "dbg-foo.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "b35f80a032deb2a30bc187d564b5a775")
51!2 = !{}
52!3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4, producer: "clang version 9.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
53!4 = !DIFile(filename: "dbg-bar.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "9836bb594260d883960455e7d8bc51ea")
54!5 = !{!"clang version 9.0.0 "}
55!6 = !{i32 2, !"Dwarf Version", i32 5}
56!7 = !{i32 2, !"Debug Info Version", i32 3}
57!8 = !{i32 1, !"wchar_size", i32 4}
58!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 7, type: !10, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
59!10 = !DISubroutineType(types: !11)
60!11 = !{!12, !12}
61!12 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
62!13 = !DILocalVariable(name: "x", arg: 1, scope: !9, file: !1, line: 7, type: !12)
63!14 = !DILocation(line: 7, column: 29, scope: !9)
64!15 = !DILocalVariable(name: "y", scope: !9, file: !1, line: 9, type: !16)
65!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
66!17 = !DILocation(line: 9, column: 14, scope: !9)
67!18 = !DILocation(line: 10, column: 3, scope: !9)
68!19 = distinct !DISubprogram(name: "bar", scope: !4, file: !4, line: 1, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !2)
69!20 = !DILocalVariable(name: "x", arg: 1, scope: !19, file: !4, line: 1, type: !12)
70!21 = !DILocation(line: 1, column: 29, scope: !19)
71!22 = !DILocalVariable(name: "z", scope: !19, file: !4, line: 3, type: !23)
72!23 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
73!24 = !DILocation(line: 3, column: 16, scope: !19)
74!25 = !DILocation(line: 4, column: 3, scope: !19)
75