diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -1154,7 +1154,11 @@ // location's lexical scope. In this case, splitting of an interval // can result in an interval outside of the scope being created, // causing extra unnecessary DBG_VALUEs to be emitted. To prevent - // this, trim the intervals to the lexical scope. + // this, trim the intervals to the lexical scope in the case of inlined + // variables, since heavy inlining may cause production of dramatically big + // number of DBG_VALUEs to be generated. + if (!dl.getInlinedAt()) + return; LexicalScope *Scope = LS.findLexicalScope(dl); if (!Scope) diff --git a/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll b/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll --- a/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll +++ b/llvm/test/CodeGen/AMDGPU/ptr-arg-dbg-value.ll @@ -14,10 +14,10 @@ ; CHECK-NEXT: .cfi_startproc ; CHECK-NEXT: ; %bb.0: ; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 32 32] [$vgpr1+0] +; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0] ; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; CHECK-NEXT: v_mov_b32_e32 v2, 1 ; CHECK-NEXT: .Ltmp0: -; CHECK-NEXT: ;DEBUG_VALUE: ptr_arg_split_subregs:a <- [DW_OP_LLVM_fragment 0 32] [$vgpr0+0] ; CHECK-NEXT: .loc 1 7 13 prologue_end ; example.cpp:7:13 ; CHECK-NEXT: flat_store_dword v[0:1], v2 offset:396 ; CHECK-NEXT: .loc 1 8 5 ; example.cpp:8:5 diff --git a/llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll b/llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll --- a/llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll +++ b/llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll @@ -5,6 +5,7 @@ ; CHECK-LABEL: test: ; CHECK: # %bb.0: # %entry ; CHECK-NEXT: #DEBUG_VALUE: test:Fptr <- $x3 +; CHECK-NEXT: #DEBUG_VALUE: test:Fptr <- $x3 ; CHECK-NEXT: #DEBUG_VALUE: test:Vptr <- $x4 ; CHECK-NEXT: addis 5, 2, .LCPI0_0@toc@ha ; CHECK-NEXT: .Ltmp0: @@ -12,7 +13,6 @@ ; CHECK-NEXT: lfsx 0, 0, 3 ; CHECK-NEXT: addis 3, 2, .LCPI0_1@toc@ha ; CHECK-NEXT: .Ltmp1: -; CHECK-NEXT: #DEBUG_VALUE: test:Fptr <- $x3 ; CHECK-NEXT: .loc 1 0 38 is_stmt 0 ; CHECK-NEXT: lfs 1, .LCPI0_0@toc@l(5) ; CHECK-NEXT: lfd 2, .LCPI0_1@toc@l(3) diff --git a/llvm/test/DebugInfo/MIR/Mips/livedebugvars-stop-trimming-loc.mir b/llvm/test/DebugInfo/MIR/Mips/livedebugvars-stop-trimming-loc.mir new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/Mips/livedebugvars-stop-trimming-loc.mir @@ -0,0 +1,119 @@ +# RUN: llc -run-pass=greedy -run-pass=virtregrewriter %s -o - | FileCheck %s + +## This tests that LiveDebugVariables does not trim non-inlined variable +## location. + +# CHECK: ![[VARB:.*]] = !DILocalVariable(name: "b" +# CHECK: ![[VARC:.*]] = !DILocalVariable(name: "c" +# CHECK: $at = COPY $a2 +# CHECK-NEXT: DBG_VALUE $at, $noreg, ![[VARC]], !DIExpression(), debug-location +# CHECK: $s0 = COPY $a1 +# CHECK-NEXT: DBG_VALUE $s0, $noreg, ![[VARB]], !DIExpression(), debug-location + +--- | + ; ModuleID = 'test.c' + source_filename = "test.c" + target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64" + target triple = "mips-unknown-linux-gnu" + + ; Function Attrs: nounwind + define dso_local i32 @fn2(i32 signext %a, i32 signext %b, i32 signext %c) local_unnamed_addr !dbg !7 { + entry: + call void @llvm.dbg.value(metadata i32 %a, metadata !12, metadata !DIExpression()), !dbg !16 + call void @llvm.dbg.value(metadata i32 %b, metadata !13, metadata !DIExpression()), !dbg !16 + call void @llvm.dbg.value(metadata i32 %c, metadata !14, metadata !DIExpression()), !dbg !16 + %add = add nsw i32 %b, %a, !dbg !17 + %add1 = add nsw i32 %b, 10, !dbg !18 + %call = tail call i32 @fn1(i32 signext %add, i32 signext %c, i32 signext %add1), !dbg !19 + call void @llvm.dbg.value(metadata i32 %call, metadata !15, metadata !DIExpression()), !dbg !16 + %cmp = icmp sgt i32 %call, 10, !dbg !20 + %add2 = add nsw i32 %call, 10, !dbg !22 + %retval.0 = select i1 %cmp, i32 %add2, i32 %b, !dbg !22 + ret i32 %retval.0, !dbg !23 + } + + declare !dbg !24 dso_local i32 @fn1(i32 signext, i32 signext, i32 signext) local_unnamed_addr + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn mustprogress + declare void @llvm.dbg.value(metadata, metadata, metadata) + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5} + !llvm.ident = !{!6} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "test.c", directory: "/dir") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{!"clang version 13.0.0"} + !7 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11) + !8 = !DISubroutineType(types: !9) + !9 = !{!10, !10, !10, !10} + !10 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !11 = !{!12, !13, !14, !15} + !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10) + !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 2, type: !10) + !14 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 2, type: !10) + !15 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 3, type: !10) + !16 = !DILocation(line: 0, scope: !7) + !17 = !DILocation(line: 3, column: 22, scope: !7) + !18 = !DILocation(line: 3, column: 30, scope: !7) + !19 = !DILocation(line: 3, column: 17, scope: !7) + !20 = !DILocation(line: 4, column: 14, scope: !21) + !21 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 8) + !22 = !DILocation(line: 4, column: 8, scope: !7) + !23 = !DILocation(line: 7, column: 2, scope: !7) + !24 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + +... +--- +name: fn2 +alignment: 4 +tracksRegLiveness: true +registers: + - { id: 0, class: gpr32, preferred-register: '' } + - { id: 1, class: gpr32, preferred-register: '' } + - { id: 2, class: gpr32, preferred-register: '' } + - { id: 3, class: gpr32, preferred-register: '' } + - { id: 4, class: gpr32, preferred-register: '' } + - { id: 5, class: gpr32, preferred-register: '' } + - { id: 6, class: gpr32, preferred-register: '' } + - { id: 7, class: gpr32, preferred-register: '' } + - { id: 8, class: gpr32, preferred-register: '' } +liveins: + - { reg: '$a0', virtual-reg: '%0' } + - { reg: '$a1', virtual-reg: '%1' } + - { reg: '$a2', virtual-reg: '%2' } +body: | + bb.0.entry: + liveins: $a0, $a1, $a2 + + DBG_VALUE $a0, $noreg, !12, !DIExpression(), debug-location !16 + DBG_VALUE $a1, $noreg, !13, !DIExpression(), debug-location !16 + DBG_VALUE $a2, $noreg, !14, !DIExpression(), debug-location !16 + %2:gpr32 = COPY $a2 + DBG_VALUE %2, $noreg, !14, !DIExpression(), debug-location !16 + %8:gpr32 = COPY $a1 + DBG_VALUE %8, $noreg, !13, !DIExpression(), debug-location !16 + %0:gpr32 = COPY $a0 + DBG_VALUE %0, $noreg, !12, !DIExpression(), debug-location !16 + %3:gpr32 = nsw ADDu %8, %0, debug-location !17 + ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp, debug-location !19 + %4:gpr32 = nsw ADDiu %8, 10, debug-location !18 + $a0 = COPY %3, debug-location !19 + $a1 = COPY %2, debug-location !19 + DBG_VALUE $a1, $noreg, !14, !DIExpression(), debug-location !16 + $a2 = COPY %4, debug-location !19 + JAL @fn1, csr_o32, implicit-def dead $ra, implicit $a0, implicit $a1, implicit $a2, implicit-def $sp, implicit-def $v0, debug-location !19 + ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp, debug-location !19 + %5:gpr32 = COPY killed $v0, debug-location !19 + DBG_VALUE %5, $noreg, !15, !DIExpression(), debug-location !16 + %6:gpr32 = SLTi %5, 11, debug-location !22 + %7:gpr32 = nsw ADDiu %5, 10, debug-location !22 + %8:gpr32 = MOVZ_I_I %7, %6, %8, debug-location !22 + $v0 = COPY %8, debug-location !23 + RetRA implicit killed $v0, debug-location !23 + +... diff --git a/llvm/test/DebugInfo/X86/dbg-addr-dse.ll b/llvm/test/DebugInfo/X86/dbg-addr-dse.ll --- a/llvm/test/DebugInfo/X86/dbg-addr-dse.ll +++ b/llvm/test/DebugInfo/X86/dbg-addr-dse.ll @@ -46,8 +46,8 @@ } ; ASM-LABEL: f: # @f -; ASM: movl %ecx, [[OFF_X:[0-9]+]](%rsp) -; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0] +; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X:[0-9]+]]] [$rsp+0] +; ASM: movl %ecx, [[OFF_X]](%rsp) ; ASM: callq escape ; ASM: #DEBUG_VALUE: f:x <- 1 ; ASM: movl $1, global(%rip)