Index: llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp =================================================================== --- llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -1641,11 +1641,6 @@ LocIdx SrcIdx = MTracker->getSpillMLoc(SpillID); auto ReadValue = MTracker->readMLoc(SrcIdx); MTracker->setReg(DestReg, ReadValue); - - if (TTracker) { - LocIdx DstLoc = MTracker->getRegMLoc(DestReg); - TTracker->transferMlocs(SrcIdx, DstLoc, MI.getIterator()); - } }; for (MCSubRegIterator SRI(Reg, TRI, false); SRI.isValid(); ++SRI) { Index: llvm/test/DebugInfo/COFF/pieces.ll =================================================================== --- llvm/test/DebugInfo/COFF/pieces.ll +++ llvm/test/DebugInfo/COFF/pieces.ll @@ -105,8 +105,6 @@ ; ASM: #APP ; ASM: #NO_APP ; ASM: movl [[offset_o_x]](%rsp), %eax # 4-byte Reload -; ASM: [[spill_o_x_end:\.Ltmp[0-9]+]]: -; ASM: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 32 32] $eax ; ASM: retq ; ASM: [[spill_o_x_end_func:\.Ltmp[0-9]+]]: ; ASM-NEXT: .Lfunc_end4: @@ -235,8 +233,7 @@ ; ASM: .asciz "bitpiece_spill" # Function name ; ASM: .short 4414 # Record kind: S_LOCAL ; ASM: .asciz "o" -; ASM: .cv_def_range [[spill_o_x_start]] [[spill_o_x_end]], reg_rel, 335, 65, 36 -; ASM: .cv_def_range [[spill_o_x_end]] .Lfunc_end4, subfield_reg, 17, 4 +; ASM: .cv_def_range [[spill_o_x_start]] .Lfunc_end4, reg_rel, 335, 65, 36 ; OBJ-LABEL: GlobalProcIdSym { ; OBJ: Kind: S_GPROC32_ID (0x1147) Index: llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_recover_clobbers.mir =================================================================== --- llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_recover_clobbers.mir +++ llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_recover_clobbers.mir @@ -76,6 +76,17 @@ ; CHECK-NEXT: $ebx = MOV32ri ; CHECK-NEXT: DBG_VALUE $rsp + ;; Try re-loading the variable value from the stack; we shouldn't issue a + ;; DBG_VALUE to follow it, the stack locations are usually longer lived and + ;; this reduces location list entropy. Then, clobber the stack location, + ;; and check that we can relocate the variable to being in the loaded + ;; register. + $ebx = MOV32rm $rsp, 1, _, -12, _ :: (load 4 from %stack.0) + MOV32mr $rsp, 1, _, -12, _, killed $esi :: (store 4 into %stack.0) + ; CHECK: $ebx = MOV32rm + ; CHECK-NEXT: MOV32mr $rsp + ; CHECK-NEXT: DBG_VALUE $ebx + ;; Now test copies and register masks. $eax = COPY $ebx DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 Index: llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir =================================================================== --- llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir +++ llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir @@ -34,6 +34,8 @@ # Check for the restore. # CHECK: $rdi = MOV64rm $rsp,{{.*-8.*}}:: (load (s64) from %stack.0) +# CHECK-NEXT: $rax = MOV64ri 0 +# CHECK-NEXT: MOV64mr # CHECK-NEXT: DBG_VALUE $rdi,{{.*}}![[PVAR]], !DIExpression() --- | @@ -310,6 +312,9 @@ MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0) INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !18 renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0) + ; Clobber stack location to force variable location to move to $rdi. + $rax = MOV64ri 0 + MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0) $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 48 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp @@ -491,6 +496,9 @@ MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0) INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !220, debug-location !218 renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0) + ; Clobber stack location to force variable location to move to $rdi. + $rax = MOV64ri 0 + MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0) $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 48 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp @@ -628,6 +636,9 @@ liveins: $rbx, $r12, $r13, $r14, $r15, $rbp renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0) + ; Clobber stack location to force variable location to move to $rdi. + $rax = MOV64ri 0 + MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0) renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !323 :: (load (s32) from %ir.add.ptr, !tbaa !24) RET64 $eax, debug-location !328 @@ -715,6 +726,9 @@ MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %stack.0) INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !409 renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load (s64) from %stack.0) + ; Clobber stack location to force variable location to move to $rdi. + $rax = MOV64ri 0 + MOV64mr $rsp, 1, _, -8, _, killed renamable $rax :: (store (s64) into %stack.0) $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 48 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp Index: llvm/test/DebugInfo/X86/pr34545.ll =================================================================== --- llvm/test/DebugInfo/X86/pr34545.ll +++ llvm/test/DebugInfo/X86/pr34545.ll @@ -1,7 +1,7 @@ ; RUN: llc -O1 -filetype=asm -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 \ ; RUN: -o - %s -stop-after=livedebugvars \ ; RUN: -experimental-debug-variable-locations=false \ -; RUN: | FileCheck %s --check-prefixes=CHECK +; RUN: | FileCheck %s --check-prefixes=CHECK,VARLOCS ; RUN: llc -O1 -filetype=asm -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 \ ; RUN: -o - %s -stop-after=livedebugvars \ ; RUN: -experimental-debug-variable-locations=true \ @@ -16,7 +16,7 @@ ; INSTRREF: DBG_INSTR_REF 2, 0 ; CHECK: DBG_VALUE $eax ; CHECK: DBG_VALUE $rsp, 0, !{{[0-9]+}}, !DIExpression(DW_OP_constu, 4, DW_OP_minus) -; CHECK: DBG_VALUE $eax +; VARLOCS: DBG_VALUE $eax ; CHECK: $eax = SHL32rCL killed renamable $eax, ; INSTRREF-SAME: debug-instr-number 3 ; INSTRREF: DBG_INSTR_REF 3, 0 Index: llvm/test/DebugInfo/X86/spill-nospill.ll =================================================================== --- llvm/test/DebugInfo/X86/spill-nospill.ll +++ llvm/test/DebugInfo/X86/spill-nospill.ll @@ -37,13 +37,11 @@ ; CHECK: movl %[[CSR]], %ecx ; CHECK: callq g ; CHECK: movl [[X_OFFS]](%rsp), %eax # 4-byte Reload -; CHECK: #DEBUG_VALUE: f:x <- $eax +;; Variable value remains on stack, location left pointing there. ; CHECK: addl %[[CSR]], %eax ; DWARF: DW_TAG_variable ; DWARF-NEXT: DW_AT_location ( -; DWARF-NEXT: [{{.*}}, {{.*}}): DW_OP_breg7 RSP+36 -; DWARF-NEXT: [{{.*}}, {{.*}}): DW_OP_reg0 RAX ; DWARF-NEXT: [{{.*}}, {{.*}}): DW_OP_breg7 RSP+36) ; DWARF-NEXT: DW_AT_name ("x")