1 # These tests check that DBG_VALUE intervals are correctly coalesced (or not) in
3 # NOTE: We do not currently handle partially overlapping fragments in LDV.
5 # The IR in this file has been modified by hand, generated from this source:
16 # RUN: llc %s -start-before=machine-scheduler -stop-after=virtregrewriter -o - -experimental-debug-variable-locations=false \
17 # RUN: | FileCheck %s --implicit-check-not=DBG_VALUE
19 # Verify that DBG_VALUEs with same { Variable, Fragment } but different DIExpressions
22 # DV1 %0 "x" (deref) --+-- Do not coalesce these because DV2 refers to the same bits.
24 # DV3 %0 "x" (deref) --+
27 # CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR:[0-9]+]], !DIExpression(DW_OP_deref)
28 # CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]], !DIExpression()
29 # CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]], !DIExpression(DW_OP_deref)
31 # Verify that DBG_VALUEs with same { Variable, Fragment } and { Location, DIExpression } are
32 # coalesced if there are no intervening DBG_VALUEs with the same { Variable, Fragment }.
34 # DV1 %0 "x" (fragment 00 16) --+-- Coalesce these because DV2 refers to different bits.
35 # DV2 %0 "x" (fragment 16 16) |
36 # DV3 %0 "x" (fragment 00 16) --+
39 # CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR:[0-9]+]], !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)
40 # CHECK: DBG_VALUE %stack.0.x.addr, $noreg, ![[VAR]], !DIExpression(DW_OP_LLVM_fragment, 16, 16)
43 target triple = "x86_64-unknown-linux-gnu"
45 @global = external global i32, align 4
46 declare void @llvm.dbg.value(metadata, metadata, metadata)
47 declare void @escape(i32*)
49 define void @f1(i32 %x) !dbg !6 {
51 %x.addr = alloca i32, align 4
52 store i32 %x, i32* %x.addr, align 4
53 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !12
54 call void @escape(i32* %x.addr), !dbg !12
55 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !11, metadata !DIExpression()), !dbg !12
56 store i32 1, i32* @global, align 4, !dbg !12
57 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !12
58 store i32 2, i32* %x.addr, align 4, !dbg !12
59 call void @escape(i32* %x.addr), !dbg !12
63 define void @f2(i32 %x) !dbg !13 {
65 %x.addr = alloca i32, align 4
66 store i32 %x, i32* %x.addr, align 4
67 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !14, metadata !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)), !dbg !15
68 call void @escape(i32* %x.addr)
69 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 16, 16)), !dbg !15
70 store i32 1, i32* @global, align 4
71 call void @llvm.dbg.value(metadata i32* %x.addr, metadata !14, metadata !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16)), !dbg !15
72 store i32 2, i32* %x.addr, align 4
73 call void @escape(i32* %x.addr)
78 !llvm.module.flags = !{!3, !4}
81 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
82 !1 = !DIFile(filename: "test.c", directory: "")
84 !3 = !{i32 2, !"Dwarf Version", i32 4}
85 !4 = !{i32 2, !"Debug Info Version", i32 3}
86 !5 = !{!"clang version 11.0.0 "}
87 !6 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
88 !7 = !DISubroutineType(types: !8)
90 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
92 !11 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 3, type: !9)
93 !12 = !DILocation(line: 3, column: 12, scope: !6)
94 !13 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
95 !14 = !DILocalVariable(name: "x", arg: 1, scope: !13, file: !1, line: 21, type: !9)
96 !15 = !DILocation(line: 23, column: 12, scope: !13)
101 tracksRegLiveness: true
103 - { id: 0, name: x.addr, type: default, offset: 0, size: 4, alignment: 4,
104 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
105 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
110 MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0 :: (store (s32) into %ir.x.addr)
111 DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(DW_OP_deref), debug-location !12
112 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12
113 %1:gr64 = LEA64r %stack.0.x.addr, 1, $noreg, 0, $noreg
114 $rdi = COPY %1, debug-location !12
115 CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !12
116 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12
117 DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(), debug-location !12
118 MOV32mi $rip, 1, $noreg, @global, $noreg, 1, debug-location !12 :: (store (s32) into @global)
119 DBG_VALUE %stack.0.x.addr, $noreg, !11, !DIExpression(DW_OP_deref), debug-location !12
120 MOV32mi %stack.0.x.addr, 1, $noreg, 0, $noreg, 2, debug-location !12 :: (store (s32) into %ir.x.addr)
121 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12
122 $rdi = COPY %1, debug-location !12
123 CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !12
124 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !12
125 RET 0, debug-location !12
129 tracksRegLiveness: true
131 - { id: 0, name: x.addr, type: default, offset: 0, size: 4, alignment: 4,
132 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
133 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
138 MOV32mr %stack.0.x.addr, 1, $noreg, 0, $noreg, %0 :: (store (s32) into %ir.x.addr)
139 DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16), debug-location !15
140 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
141 %1:gr64 = LEA64r %stack.0.x.addr, 1, $noreg, 0, $noreg
143 CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
144 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
145 DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_LLVM_fragment, 16, 16), debug-location !15
146 MOV32mi $rip, 1, $noreg, @global, $noreg, 1 :: (store (s32) into @global)
147 DBG_VALUE %stack.0.x.addr, $noreg, !14, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 16), debug-location !15
148 MOV32mi %stack.0.x.addr, 1, $noreg, 0, $noreg, 2 :: (store (s32) into %ir.x.addr)
149 ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
151 CALL64pcrel32 @escape, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
152 ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp