183 lines · plain
1# RUN: llc -start-before=livedebugvalues %s -filetype=asm -o -| FileCheck %s2#3# DbgEntityHistoryCalculator should close variable's range at the end of4# the basic block when variable is referenced through non-changing frame5# pointer register. Having BB1 that branches to BB2 and BB3, where6# 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 LiveDebugValues8# wont generate DBG_VALUE for BB3. If last variable location at BB2 is9# non-changing register, DbgEntityHistoryCalculator will extend range of10# DBG_VALUE from BB2 to whole BB3 and thus produce incorrect range for11# case when we took branch BB3 from BB1.12#13# Verifies that "local1" stack location is ended at the end of the block (.Ltmp6).14#15# CHECK: .Ltmp4:16# CHECK-NEXT: #DEBUG_VALUE: foo:local1 <- [DW_OP_constu 4, DW_OP_minus, DW_OP_deref] $rbp17# CHECK: jmp .LBB0_218# CHECK-NEXT: .Ltmp6:19# CHECK: .Lfunc_end0:20#21# CHECK: .Ldebug_loc2:22# CHECK-NEXT: .quad .Ltmp1-.Lfunc_begin023# CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin024# CHECK-NEXT: .short 1 # Loc expr size25# CHECK-NEXT: .byte 94 # super-register DW_OP_reg1426# CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin027# CHECK-NEXT: .quad .Ltmp6-.Lfunc_begin028# CHECK-NEXT: .short 2 # Loc expr size29# CHECK-NEXT: .byte 118 # DW_OP_breg630# CHECK-NEXT: .byte 124 # -431#32# CHECK: .long .Ldebug_loc2 # DW_AT_location33# CHECK-NEXT: .long .Linfo_string7 # DW_AT_name34#35# CHECK: .Linfo_string7:36# CHECK-NEXT: .asciz "local1"37--- |38 ; ModuleID = 'dbg-stack-value-range.ll'39 source_filename = "dbg-stack-value-range.c"40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"41 target triple = "x86_64-unknown-linux-gnu"42 43 ; Function Attrs: nounwind uwtable44 define dso_local i32 @foo(i32 %X) local_unnamed_addr #0 !dbg !7 {45 entry:46 %local1 = alloca i32, align 447 call void @llvm.dbg.value(metadata i32 %X, metadata !12, metadata !DIExpression()), !dbg !1548 %0 = bitcast ptr %local1 to ptr, !dbg !1549 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0), !dbg !1550 call void @llvm.dbg.value(metadata i32 5, metadata !14, metadata !DIExpression()), !dbg !1551 %call = tail call i32 (...) @check(), !dbg !1552 %tobool = icmp eq i32 %call, 0, !dbg !1553 br i1 %tobool, label %if.else, label %if.then, !dbg !1554 55 if.then: ; preds = %entry56 call void @llvm.dbg.value(metadata i32 4, metadata !13, metadata !DIExpression()), !dbg !1557 store i32 4, ptr %local1, align 4, !dbg !15, !tbaa !1658 call void @llvm.dbg.value(metadata ptr %local1, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !1559 %call1 = call i32 @init(ptr nonnull %local1), !dbg !1560 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !1561 br label %if.end, !dbg !1562 63 if.else: ; preds = %entry64 call void @llvm.dbg.value(metadata i32 5, metadata !13, metadata !DIExpression()), !dbg !1565 store i32 5, ptr %local1, align 4, !dbg !15, !tbaa !1666 br label %if.end67 68 if.end: ; preds = %if.else, %if.then69 %1 = bitcast ptr %local1 to ptr, !dbg !1570 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !1571 %call2 = call i32 (...) @init2(), !dbg !1572 call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !1573 %2 = load i32, ptr %local1, align 4, !dbg !15, !tbaa !1674 call void @llvm.dbg.value(metadata i32 %2, metadata !13, metadata !DIExpression()), !dbg !1575 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1), !dbg !1576 ret i32 %2, !dbg !1577 }78 79 ; Function Attrs: argmemonly nounwind80 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)81 82 declare dso_local i32 @check(...) local_unnamed_addr83 84 declare dso_local i32 @init(ptr) local_unnamed_addr85 86 declare dso_local i32 @init2(...) local_unnamed_addr87 88 ; Function Attrs: argmemonly nounwind89 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)90 91 ; Function Attrs: nounwind readnone speculatable92 declare void @llvm.dbg.value(metadata, metadata, metadata)93 94 ; Function Attrs: nounwind95 declare void @llvm.stackprotector(ptr, ptr)96 97 attributes #0 = { nounwind uwtable "frame-pointer"="non-leaf" }98 99 !llvm.dbg.cu = !{!0}100 !llvm.module.flags = !{!3, !4, !5}101 !llvm.ident = !{!6}102 103 !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)104 !1 = !DIFile(filename: "dbg-stack-value-range.c", directory: "/")105 !2 = !{}106 !3 = !{i32 2, !"Dwarf Version", i32 4}107 !4 = !{i32 2, !"Debug Info Version", i32 3}108 !5 = !{i32 1, !"wchar_size", i32 4}109 !6 = !{!"clang version 9.0.0"}110 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !8, scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)111 !8 = !DISubroutineType(types: !9)112 !9 = !{!10, !10}113 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)114 !11 = !{!12, !13, !14}115 !12 = !DILocalVariable(name: "X", arg: 1, scope: !7, file: !1, line: 11, type: !10)116 !13 = !DILocalVariable(name: "local1", scope: !7, file: !1, line: 12, type: !10)117 !14 = !DILocalVariable(name: "local2", scope: !7, file: !1, line: 12, type: !10)118 !15 = !DILocation(line: 11, column: 13, scope: !7)119 !16 = !{!17, !17, i64 0}120 !17 = !{!"int", !18, i64 0}121 !18 = !{!"omnipotent char", !19, i64 0}122 !19 = !{!"Simple C/C++ TBAA"}123 124...125---126name: foo127alignment: 16128frameInfo: 129 stackSize: 24130 offsetAdjustment: -24131 maxAlignment: 4132 adjustsStack: true133 hasCalls: true134fixedStack: 135 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default, 136 callee-saved-register: '$r14d', callee-saved-restored: true, debug-info-variable: '', 137 debug-info-expression: '', debug-info-location: '' }138stack: 139 - { id: 0, name: local1, type: default, offset: -20, size: 4, alignment: 4, 140 stack-id: default, callee-saved-register: '', callee-saved-restored: true, 141 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }142body: |143 bb.0.entry:144 successors: %bb.3(0x30000000), %bb.1(0x50000000)145 146 DBG_VALUE $edi, $noreg, !12, !DIExpression(), debug-location !15147 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp148 CFI_INSTRUCTION def_cfa_offset 16149 CFI_INSTRUCTION offset $rbp, -16150 $rbp = frame-setup MOV64rr $rsp151 CFI_INSTRUCTION def_cfa_register $rbp152 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags153 DBG_VALUE 5, $noreg, !14, !DIExpression(), debug-location !15154 $r14d = MOV32ri 4, implicit-def $r14155 DBG_VALUE $r14d, $noreg, !13, !DIExpression(), debug-location !15156 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !15157 CALL64pcrel32 @check, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15158 TEST32rr killed renamable $eax, renamable $eax, implicit-def $eflags, debug-location !15159 JCC_1 %bb.3, 4, implicit killed $eflags, debug-location !15160 161 bb.1.if.then:162 successors: %bb.3(0x80000000)163 164 MOV32mr $rbp, 1, $noreg, -4, $noreg, $r14d, debug-location !15 :: (store (s32) into %ir.local1, !tbaa !16)165 DBG_VALUE $rbp, $noreg, !13, !DIExpression(DW_OP_constu, 4, DW_OP_minus, DW_OP_deref), debug-location !15166 renamable $rdi = LEA64r $rbp, 1, $noreg, -4, $noreg167 CALL64pcrel32 @init, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !15168 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15169 JMP_1 %bb.3170 171 bb.3.if.end:172 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15173 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !15174 CALL64pcrel32 @init2, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !15175 DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !15176 renamable $eax = MOV32rm $rbp, 1, $noreg, -4, $noreg, debug-location !15 :: (dereferenceable load (s32) from %ir.local1, !tbaa !16)177 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !15178 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15179 CFI_INSTRUCTION def_cfa $rsp, 8, debug-location !15180 RET64 $eax, debug-location !15181 182...183