1 ; RUN: llc -mtriple=x86_64-unknown-unknown -stop-before livedebugvalues %s -o -\
2 ; RUN: -experimental-debug-variable-locations=false \
3 ; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE
4 ; RUN: llc -mtriple=x86_64-unknown-unknown -stop-before livedebugvalues %s -o -\
5 ; RUN: -experimental-debug-variable-locations=true \
6 ; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF
8 ; Generated at -O1 from:
10 ; unsigned long long c;
13 ; unsigned long long packed;
18 ; void f(struct S3 *a3)
20 ; struct S4 *s4 = (struct S4 *)(a3->packed + 0x1000UL);
21 ; struct S6 *myVar = (struct S6 *)s4;
22 ; struct S0 *b = myVar->b;
26 ; The debug info is attached to the ADD 4096 operation, which doesn't survive
27 ; instruction selection as it is folded into the load. As a result, we should
28 ; refer to s4 and myVar with complex expressions.
30 ; CHECK: ![[S4:.*]] = !DILocalVariable(name: "s4",
31 ; CHECK: ![[MYVAR:.*]] = !DILocalVariable(name: "myVar",
32 ; CHECK: $rax = MOV64rm
33 ; INSTRREF-SAME: debug-instr-number 2,
34 ; INSTRREF-NEXT: DBG_INSTR_REF ![[S4]],
35 ; DBGVALUE-NEXT: DBG_VALUE $rax, $noreg, ![[S4]],
36 ; DBGVALUE-SAME: !DIExpression(DW_OP_plus_uconst, 4096, DW_OP_stack_value)
37 ; INSTRREF-SAME: !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 4096, DW_OP_stack_value)
38 ; INSTRREF-SAME: dbg-instr-ref(2, 0)
40 ; INSTRREF: DBG_INSTR_REF ![[MYVAR]],
41 ; DBGVALUE: DBG_VALUE $rax, $noreg, ![[MYVAR]],
42 ; DBGVALUE-SAME: !DIExpression(DW_OP_plus_uconst, 4096, DW_OP_stack_value)
43 ; INSTRREF-SAME: !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 4096, DW_OP_stack_value)
44 ; INSTRREF-SAME: dbg-instr-ref(2, 0)
45 ; CHECK-NEXT: $rdi = MOV64rm killed renamable $rax, 1, $noreg, 4096, $noreg,
47 source_filename = "test.c"
48 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
49 target triple = "x86_64-apple-macosx10.13.0"
51 %struct.S3 = type { i64 }
52 %struct.S4 = type opaque
53 %struct.S0 = type opaque
55 ; Function Attrs: noinline nounwind ssp uwtable
56 define void @f(ptr nocapture readonly %a3) local_unnamed_addr #0 !dbg !6 {
58 tail call void @llvm.dbg.value(metadata ptr %a3, metadata !15, metadata !DIExpression()), !dbg !30
59 %0 = load i64, ptr %a3, align 8, !dbg !31
60 %add = add i64 %0, 4096, !dbg !37
61 %1 = inttoptr i64 %add to ptr, !dbg !38
62 tail call void @llvm.dbg.value(metadata ptr %1, metadata !16, metadata !DIExpression()), !dbg !39
63 tail call void @llvm.dbg.value(metadata ptr %1, metadata !17, metadata !DIExpression()), !dbg !40
64 %2 = load ptr, ptr %1, align 8, !dbg !41
65 tail call void @llvm.dbg.value(metadata ptr %2, metadata !24, metadata !DIExpression()), !dbg !45
66 %call = tail call i32 (ptr, ...) @use(ptr %2) #3, !dbg !46
70 declare i32 @use(...) local_unnamed_addr
72 ; Function Attrs: nounwind readnone speculatable
73 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
75 attributes #0 = { noinline nounwind ssp uwtable }
76 attributes #2 = { nounwind readnone speculatable }
77 attributes #3 = { nounwind }
80 !llvm.module.flags = !{!25, !26, !27, !28}
83 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 316467) (llvm/trunk 316466)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
84 !1 = !DIFile(filename: "test.c", directory: "/")
87 !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
88 !5 = !DICompositeType(tag: DW_TAG_structure_type, name: "S4", scope: !6, file: !1, line: 20, flags: DIFlagFwdDecl)
89 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 18, type: !7, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !14)
90 !7 = !DISubroutineType(types: !8)
92 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
93 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S3", file: !1, line: 5, size: 64, elements: !11)
95 !12 = !DIDerivedType(tag: DW_TAG_member, name: "packed", scope: !10, file: !1, line: 6, baseType: !13, size: 64)
96 !13 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned)
97 !14 = !{!15, !16, !17, !24}
98 !15 = !DILocalVariable(name: "a3", arg: 1, scope: !6, file: !1, line: 18, type: !9)
99 !16 = !DILocalVariable(name: "s4", scope: !6, file: !1, line: 20, type: !4)
100 !17 = !DILocalVariable(name: "myVar", scope: !6, file: !1, line: 21, type: !18)
101 !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
102 !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S6", file: !1, line: 8, size: 64, elements: !20)
104 !21 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !19, file: !1, line: 9, baseType: !22, size: 64)
105 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)
106 !23 = !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !1, line: 4, flags: DIFlagFwdDecl)
107 !24 = !DILocalVariable(name: "b", scope: !6, file: !1, line: 22, type: !22)
108 !25 = !{i32 2, !"Dwarf Version", i32 4}
109 !26 = !{i32 2, !"Debug Info Version", i32 3}
110 !27 = !{i32 1, !"wchar_size", i32 4}
111 !28 = !{i32 7, !"PIC Level", i32 2}
112 !29 = !{!"clang version 6.0.0 (trunk 316467) (llvm/trunk 316466)"}
113 !30 = !DILocation(line: 18, column: 14, scope: !6)
114 !31 = !DILocation(line: 20, column: 37, scope: !6)
115 !37 = !DILocation(line: 20, column: 44, scope: !6)
116 !38 = !DILocation(line: 20, column: 19, scope: !6)
117 !39 = !DILocation(line: 20, column: 14, scope: !6)
118 !40 = !DILocation(line: 21, column: 14, scope: !6)
119 !41 = !DILocation(line: 22, column: 25, scope: !6)
120 !45 = !DILocation(line: 22, column: 14, scope: !6)
121 !46 = !DILocation(line: 23, column: 3, scope: !6)
122 !47 = !DILocation(line: 24, column: 1, scope: !6)