1 # RUN: llc -start-before=livedebugvalues %s -filetype=asm -o -| FileCheck %s
3 # DbgEntityHistoryCalculator should close variable's range at the end of
4 # the basic block when variable is referenced through non-changing frame
5 # pointer register. Having BB1 that branches to BB2 and BB3, where
6 # BB2 falls through to BB3, variable can have different locations at BB1 and BB2.
7 # Since input locations at BB3 for same variable are different LiveDebugValues
8 # wont generate DBG_VALUE for BB3. If last variable location at BB2 is
9 # non-changing register, DbgEntityHistoryCalculator will extend range of
10 # DBG_VALUE from BB2 to whole BB3 and thus produce incorrect range for
11 # case when we took branch BB3 from BB1.
13 # Verifies that "local1" stack location is ended at the end of the block (.Ltmp6).
16 # CHECK-NEXT: #DEBUG_VALUE: foo:local1 <- [DW_OP_constu 4, DW_OP_minus, DW_OP_deref] $rbp
21 # CHECK: .Linfo_string7:
22 # CHECK-NEXT: .asciz "local1"
24 # CHECK: .Ldebug_loc2:
25 # CHECK-NEXT: .quad .Ltmp1-.Lfunc_begin0
26 # CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin0
27 # CHECK-NEXT: .short 1 # Loc expr size
28 # CHECK-NEXT: .byte 94 # super-register DW_OP_reg14
29 # CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin0
30 # CHECK-NEXT: .quad .Ltmp6-.Lfunc_begin0
31 # CHECK-NEXT: .short 2 # Loc expr size
32 # CHECK-NEXT: .byte 118 # DW_OP_breg6
33 # CHECK-NEXT: .byte 124 # -4
35 # CHECK: .long .Ldebug_loc2 # DW_AT_location
36 # CHECK-NEXT: .long .Linfo_string7 # DW_AT_name
40 ; ModuleID = 'dbg-stack-value-range.ll'
41 source_filename = "dbg-stack-value-range.c"
42 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
43 target triple = "x86_64-unknown-linux-gnu"
45 ; Function Attrs: nounwind uwtable
46 define dso_local i32 @foo(i32 %X) local_unnamed_addr #0 !dbg !7 {
48 %local1 = alloca i32, align 4
49 call void @llvm.dbg.value(metadata i32 %X, metadata !12, metadata !DIExpression()), !dbg !15
50 %0 = bitcast i32* %local1 to i8*, !dbg !15
51 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !15
52 call void @llvm.dbg.value(metadata i32 5, metadata !14, metadata !DIExpression()), !dbg !15
53 %call = tail call i32 (...) @check(), !dbg !15
54 %tobool = icmp eq i32 %call, 0, !dbg !15
55 br i1 %tobool, label %if.else, label %if.then, !dbg !15
57 if.then: ; preds = %entry
58 call void @llvm.dbg.value(metadata i32 4, metadata !13, metadata !DIExpression()), !dbg !15
59 store i32 4, i32* %local1, align 4, !dbg !15, !tbaa !16
60 call void @llvm.dbg.value(metadata i32* %local1, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !15
61 %call1 = call i32 @init(i32* nonnull %local1), !dbg !15
62 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !15
63 br label %if.end, !dbg !15
65 if.else: ; preds = %entry
66 call void @llvm.dbg.value(metadata i32 5, metadata !13, metadata !DIExpression()), !dbg !15
67 store i32 5, i32* %local1, align 4, !dbg !15, !tbaa !16
70 if.end: ; preds = %if.else, %if.then
71 %1 = bitcast i32* %local1 to i8*, !dbg !15
72 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !15
73 %call2 = call i32 (...) @init2(), !dbg !15
74 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !15
75 %2 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !16
76 call void @llvm.dbg.value(metadata i32 %2, metadata !13, metadata !DIExpression()), !dbg !15
77 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %1), !dbg !15
81 ; Function Attrs: argmemonly nounwind
82 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
84 declare dso_local i32 @check(...) local_unnamed_addr
86 declare dso_local i32 @init(i32*) local_unnamed_addr
88 declare dso_local i32 @init2(...) local_unnamed_addr
90 ; Function Attrs: argmemonly nounwind
91 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
93 ; Function Attrs: nounwind readnone speculatable
94 declare void @llvm.dbg.value(metadata, metadata, metadata)
96 ; Function Attrs: nounwind
97 declare void @llvm.stackprotector(i8*, i8**)
99 attributes #0 = { nounwind uwtable "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" }
102 !llvm.module.flags = !{!3, !4, !5}
105 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
106 !1 = !DIFile(filename: "dbg-stack-value-range.c", directory: "/")
108 !3 = !{i32 2, !"Dwarf Version", i32 4}
109 !4 = !{i32 2, !"Debug Info Version", i32 3}
110 !5 = !{i32 1, !"wchar_size", i32 4}
111 !6 = !{!"clang version 9.0.0"}
112 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !8, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
113 !8 = !DISubroutineType(types: !9)
115 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
116 !11 = !{!12, !13, !14}
117 !12 = !DILocalVariable(name: "X", arg: 1, scope: !7, file: !1, line: 11, type: !10)
118 !13 = !DILocalVariable(name: "local1", scope: !7, file: !1, line: 12, type: !10)
119 !14 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 12, type: !10)
120 !15 = !DILocation(line: 11, column: 13, scope: !7)
121 !16 = !{!17, !17, i64 0}
122 !17 = !{!"int", !18, i64 0}
123 !18 = !{!"omnipotent char", !19, i64 0}
124 !19 = !{!"Simple C/C++ TBAA"}
132 offsetAdjustment: -24
137 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
138 callee-saved-register: '$r14d', callee-saved-restored: true, debug-info-variable: '',
139 debug-info-expression: '', debug-info-location: '' }
141 - { id: 0, name: local1, type: default, offset: -20, size: 4, alignment: 4,
142 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
143 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
146 successors: %bb.3(0x30000000), %bb.1(0x50000000)
148 DBG_VALUE $edi, $noreg, !12, !DIExpression(), debug-location !15
149 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
150 CFI_INSTRUCTION def_cfa_offset 16
151 CFI_INSTRUCTION offset $rbp, -16
152 $rbp = frame-setup MOV64rr $rsp
153 CFI_INSTRUCTION def_cfa_register $rbp
154 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
155 DBG_VALUE 5, $noreg, !14, !DIExpression(), debug-location !15
156 $r14d = MOV32ri 4, implicit-def $r14
157 DBG_VALUE $r14d, $noreg, !13, !DIExpression(), debug-location !15
158 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !15
159 CALL64pcrel32 @check, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
160 TEST32rr killed renamable $eax, renamable $eax, implicit-def $eflags, debug-location !15
161 JCC_1 %bb.3, 4, implicit killed $eflags, debug-location !15
164 successors: %bb.3(0x80000000)
166 MOV32mr $rbp, 1, $noreg, -4, $noreg, $r14d, debug-location !15 :: (store 4 into %ir.local1, !tbaa !16)
167 DBG_VALUE $rbp, $noreg, !13, !DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref), debug-location !15
168 renamable $rdi = LEA64r $rbp, 1, $noreg, -4, $noreg
169 CALL64pcrel32 @init, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !15
170 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15
174 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15
175 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !15
176 CALL64pcrel32 @init2, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !15
177 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15
178 renamable $eax = MOV32rm $rbp, 1, $noreg, -4, $noreg, debug-location !15 :: (dereferenceable load 4 from %ir.local1, !tbaa !16)
179 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !15
180 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15
181 CFI_INSTRUCTION def_cfa $rsp, 8, debug-location !15
182 RETQ $eax, debug-location !15