1 ; RUN: llc %s -stop-before finalize-isel -o - \
2 ; RUN: -experimental-debug-variable-locations=false \
3 ; RUN: -debug-ata-coalesce-frags=true \
4 ; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE --implicit-check-not=DBG_VALUE
6 ; RUN: llc --try-experimental-debuginfo-iterators %s -stop-before finalize-isel -o - \
7 ; RUN: -experimental-debug-variable-locations=false \
8 ; RUN: -debug-ata-coalesce-frags=true \
9 ; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE --implicit-check-not=DBG_VALUE
10 ; RUN: llc %s -stop-before finalize-isel -o - \
11 ; RUN: -experimental-debug-variable-locations=true \
12 ; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF --implicit-check-not=DBG_VALUE \
13 ; RUN: --implicit-check-not=DBG_INSTR_REF
16 ; RUN: llc --try-experimental-debuginfo-iterators %s -stop-before finalize-isel -o - \
17 ; RUN: -experimental-debug-variable-locations=true \
18 ; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF --implicit-check-not=DBG_VALUE \
19 ; RUN: --implicit-check-not=DBG_INSTR_REF
21 ;; Check that dbg.assigns for an aggregate variable which lives on the stack
22 ;; for some of its lifetime are lowered into an appropriate set of DBG_VALUEs.
37 ;; $ clang++ test.cpp -O2 -g -emit-llvm -S -c -Xclang -fexperimental-assignment-tracking
39 ; CHECK: ![[VAR:[0-9]+]] = !DILocalVariable(name: "X",
40 ;; Check we have no debug info for local in the side table.
42 ; CHECK-NEXT: - { id: 0, name: X, type: default, offset: 0, size: 16, alignment: 8,
43 ; CHECK-NEXT: stack-id: default, callee-saved-register: '', callee-saved-restored: true,
44 ; CHECK-NEXT: debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
46 ;; Initially the whole variable is on the stack.
48 ; CHECK-NEXT: DBG_VALUE %stack.0.X, $noreg, ![[VAR]], !DIExpression(DW_OP_deref), debug-location
50 ;; Then there is a store to the upper 64 bits.
51 ; CHECK: MOV64mi32 %stack.0.X, 1, $noreg, 8, $noreg, 0, debug-location
52 ;; No change in variable location: the stack home is still valid.
54 ;; The final assignment (X.B += 2) doesn't get stored back to the alloca. This
55 ;; means that that the stack location isn't valid for the entire lifetime of X.
56 ; DBGVALUE: %2:gr64 = nsw ADD64ri32 %1, 2, implicit-def dead $eflags, debug-location
57 ; DBGVALUE-NEXT: DBG_VALUE %2, $noreg, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 64, 64), debug-location
58 ; INSTRREF: %2:gr64 = nsw ADD64ri32 %1, 2, implicit-def dead $eflags, debug-instr-number 1
59 ; INSTRREF-NEXT: DBG_INSTR_REF ![[VAR]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_fragment, 64, 64), dbg-instr-ref(1, 0), debug-location
61 ;; Bits [0, 64) are still stack homed. FIXME, this particular reinstatement is
63 ; CHECK-NEXT: DBG_VALUE %stack.0.X, $noreg, ![[VAR]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 64)
65 source_filename = "test.cpp"
66 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
67 target triple = "x86_64-unknown-linux-gnu"
69 %struct.Ex = type { i64, i64 }
71 define dso_local i64 @_Z3funv() local_unnamed_addr !dbg !7 {
73 %X = alloca %struct.Ex, align 8, !DIAssignID !17
74 call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !17, metadata ptr %X, metadata !DIExpression()), !dbg !18
75 %B = getelementptr inbounds %struct.Ex, ptr %X, i64 0, i32 1, !dbg !20
76 store i64 0, ptr %B, align 8, !dbg !21, !DIAssignID !27
77 call void @llvm.dbg.assign(metadata i64 0, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64), metadata !27, metadata ptr %B, metadata !DIExpression()), !dbg !21
78 call void @_Z3escPl(ptr nonnull %B), !dbg !28
79 %0 = load i64, ptr %B, align 8, !dbg !29
80 %add = add nsw i64 %0, 2, !dbg !29
81 call void @llvm.dbg.assign(metadata i64 %add, metadata !12, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64), metadata !30, metadata ptr %B, metadata !DIExpression()), !dbg !29
82 ret i64 %add, !dbg !32
85 declare void @llvm.lifetime.start.p0i8(i64 immarg, ptr nocapture)
86 declare !dbg !33 dso_local void @_Z3escPl(ptr) local_unnamed_addr
87 declare void @llvm.lifetime.end.p0i8(i64 immarg, ptr nocapture)
88 declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
91 !llvm.module.flags = !{!3, !4, !5, !1000}
94 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
95 !1 = !DIFile(filename: "test.cpp", directory: "/")
97 !3 = !{i32 7, !"Dwarf Version", i32 4}
98 !4 = !{i32 2, !"Debug Info Version", i32 3}
99 !5 = !{i32 1, !"wchar_size", i32 4}
100 !6 = !{!"clang version 12.0.0"}
101 !7 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
102 !8 = !DISubroutineType(types: !9)
104 !10 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
106 !12 = !DILocalVariable(name: "X", scope: !7, file: !1, line: 7, type: !13)
107 !13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Ex", file: !1, line: 2, size: 128, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS2Ex")
109 !15 = !DIDerivedType(tag: DW_TAG_member, name: "A", scope: !13, file: !1, line: 3, baseType: !10, size: 64)
110 !16 = !DIDerivedType(tag: DW_TAG_member, name: "B", scope: !13, file: !1, line: 4, baseType: !10, size: 64, offset: 64)
111 !17 = distinct !DIAssignID()
112 !18 = !DILocation(line: 0, scope: !7)
113 !19 = !DILocation(line: 7, column: 3, scope: !7)
114 !20 = !DILocation(line: 8, column: 5, scope: !7)
115 !21 = !DILocation(line: 8, column: 7, scope: !7)
116 !27 = distinct !DIAssignID()
117 !28 = !DILocation(line: 9, column: 3, scope: !7)
118 !29 = !DILocation(line: 10, column: 7, scope: !7)
119 !30 = distinct !DIAssignID()
120 !31 = !DILocation(line: 12, column: 1, scope: !7)
121 !32 = !DILocation(line: 11, column: 3, scope: !7)
122 !33 = !DISubprogram(name: "esc", linkageName: "_Z3escPl", scope: !1, file: !1, line: 1, type: !34, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
123 !34 = !DISubroutineType(types: !35)
125 !36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
126 !1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}