Index: lib/CodeGen/LiveDebugVariables.cpp =================================================================== --- lib/CodeGen/LiveDebugVariables.cpp +++ lib/CodeGen/LiveDebugVariables.cpp @@ -936,6 +936,7 @@ if (NewLocNo == UndefLocNo) { MachineOperand MO = MachineOperand::CreateReg(LI->reg, false); MO.setSubReg(locations[OldLocNo].getSubReg()); + MO.setIsDebug(locations[OldLocNo].isDebug()); NewLocNo = getLocationNo(MO); DidChange = true; } @@ -1187,6 +1188,8 @@ MachineInstrBuilder MIB = BuildMI(*MBB, I, getDebugLoc(), TII.get(TargetOpcode::DBG_VALUE)) .add(MO); + if (MO.isReg() && MO.isUse()) + MIB->getOperand(0).setIsDebug(); if (IsIndirect) MIB.addImm(0U); else Index: lib/CodeGen/MachineVerifier.cpp =================================================================== --- lib/CodeGen/MachineVerifier.cpp +++ lib/CodeGen/MachineVerifier.cpp @@ -1204,6 +1204,10 @@ return; } } + if (MI->isDebugValue() && MO->isUse() && !MO->isDebug()) { + report("Use-reg is not IsDebug in a DBG_VALUE", MO, MONum); + return; + } } else { // Virtual register. const TargetRegisterClass *RC = MRI->getRegClassOrNull(Reg); Index: lib/CodeGen/PrologEpilogInserter.cpp =================================================================== --- lib/CodeGen/PrologEpilogInserter.cpp +++ lib/CodeGen/PrologEpilogInserter.cpp @@ -1074,6 +1074,7 @@ int64_t Offset = TFI->getFrameIndexReference(MF, MI.getOperand(0).getIndex(), Reg); MI.getOperand(0).ChangeToRegister(Reg, false /*isDef*/); + MI.getOperand(0).setIsDebug(); auto *DIExpr = DIExpression::prepend(MI.getDebugExpression(), DIExpression::NoDeref, Offset); MI.getOperand(3).setMetadata(DIExpr); Index: test/CodeGen/MIR/X86/diexpr-win32.mir =================================================================== --- test/CodeGen/MIR/X86/diexpr-win32.mir +++ test/CodeGen/MIR/X86/diexpr-win32.mir @@ -194,8 +194,8 @@ CFI_INSTRUCTION def_cfa_offset 8 CFI_INSTRUCTION offset $esi, -8 $esi = MOV32rm $esp, 1, _, 8, _ :: (load 4 from %fixed-stack.2) - DBG_VALUE $esp, 0, !26, !10, debug-location !25 - DBG_VALUE $esp, 0, !23, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !25 + DBG_VALUE debug-use $esp, 0, !26, !10, debug-location !25 + DBG_VALUE debug-use $esp, 0, !23, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !25 CALLpcrel32 @getString, csr_32, implicit $esp, implicit-def $esp, implicit-def $eax, debug-location !29 $ecx = MOV32rm $eax, 1, _, 0, _, debug-location !29 :: (dereferenceable load 4 from %ir.1) $edx = MOV32rm $eax, 1, _, 4, _, debug-location !29 :: (dereferenceable load 4 from %ir.1 + 4) Index: test/CodeGen/PowerPC/debuginfo-stackarg.ll =================================================================== --- test/CodeGen/PowerPC/debuginfo-stackarg.ll +++ test/CodeGen/PowerPC/debuginfo-stackarg.ll @@ -33,7 +33,7 @@ ; We expect to find a DBG_VALUE refering to the metadata id for bar5, using the lowest ; of the two fixed stack offsets found earlier. ; CHECK-LABEL: body: -; CHECK: DBG_VALUE $r1, 0, !17, !DIExpression(DW_OP_plus_uconst, 56) +; CHECK: DBG_VALUE debug-use $r1, 0, !17, !DIExpression(DW_OP_plus_uconst, 56) entry: tail call void @llvm.dbg.value(metadata i64 %bar1, metadata !13, metadata !DIExpression()), !dbg !18 tail call void @llvm.dbg.value(metadata i64 %bar2, metadata !14, metadata !DIExpression()), !dbg !19 Index: test/CodeGen/X86/post-ra-sched-with-debug.mir =================================================================== --- test/CodeGen/X86/post-ra-sched-with-debug.mir +++ test/CodeGen/X86/post-ra-sched-with-debug.mir @@ -288,7 +288,7 @@ $rcx = LEA64r $rbp, 1, $noreg, -20, $noreg DBG_VALUE debug-use $rcx, debug-use $noreg, !46, !17, debug-location !48 DBG_VALUE debug-use $rcx, debug-use $noreg, !39, !17, debug-location !44 - DBG_VALUE $rbp, -20, !29, !17, debug-location !36 + DBG_VALUE debug-use $rbp, -20, !29, !17, debug-location !36 $rcx = CMOVNE64rr killed $rcx, killed $rdx, implicit killed $eflags $rcx = OR64rr killed $rcx, killed $rsi, implicit-def dead $eflags $rdx = MOVSX64rm32 $rbx, 1, $noreg, 0, $noreg :: (load 4, align 8) Index: test/DebugInfo/MIR/AArch64/clobber-sp.mir =================================================================== --- test/DebugInfo/MIR/AArch64/clobber-sp.mir +++ test/DebugInfo/MIR/AArch64/clobber-sp.mir @@ -149,7 +149,7 @@ STURWi killed $w0, $fp, -4 :: (store 4 into %stack.0.x.addr) DBG_VALUE debug-use $w1, debug-use _, !20, !22, debug-location !28 STRWui killed $w1, $sp, 2, debug-location !30 :: (store 4 into %stack.1) - DBG_VALUE $sp, 0, !20, !36, debug-location !28 + DBG_VALUE debug-use $sp, 0, !20, !36, debug-location !28 BL @g, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $d0, implicit killed $d1, implicit killed $d2, implicit killed $d3, implicit-def $sp, debug-location !30 $w0 = LDRWui $sp, 2, debug-location !33 :: (load 4 from %stack.1) CBZW killed $w0, %bb.2.if.end, debug-location !33 Index: test/DebugInfo/MIR/Mips/last-inst-bundled.mir =================================================================== --- test/DebugInfo/MIR/Mips/last-inst-bundled.mir +++ test/DebugInfo/MIR/Mips/last-inst-bundled.mir @@ -164,7 +164,7 @@ DBG_VALUE debug-use $a0, debug-use $noreg, !12, !DIExpression(), debug-location !17 $s0 = OR $a0, $zero DBG_VALUE debug-use $s0, debug-use $noreg, !12, !DIExpression(), debug-location !17 - DBG_VALUE $sp, 0, !13, !DIExpression(DW_OP_plus_uconst, 20), debug-location !19 + DBG_VALUE debug-use $sp, 0, !13, !DIExpression(DW_OP_plus_uconst, 20), debug-location !19 JAL @set_cond, csr_o32, implicit-def dead $ra, implicit $a0, implicit $a1, implicit-def $sp, debug-location !20 { renamable $a1 = LEA_ADDiu $sp, 20 } Index: test/DebugInfo/MIR/X86/kill-after-spill.mir =================================================================== --- test/DebugInfo/MIR/X86/kill-after-spill.mir +++ test/DebugInfo/MIR/X86/kill-after-spill.mir @@ -277,9 +277,9 @@ DBG_VALUE debug-use $edi, debug-use $noreg, !36, !DIExpression(), debug-location !57 DBG_VALUE debug-use $esi, debug-use $noreg, !37, !DIExpression(), debug-location !58 $ebx = MOV32rr $esi - DBG_VALUE $ebx, debug-use $noreg, !37, !DIExpression(), debug-location !58 + DBG_VALUE debug-use $ebx, debug-use $noreg, !37, !DIExpression(), debug-location !58 $r15d = MOV32rr $edi - DBG_VALUE $r15d, debug-use $noreg, !36, !DIExpression(), debug-location !57 + DBG_VALUE debug-use $r15d, debug-use $noreg, !36, !DIExpression(), debug-location !57 renamable $r14 = MOV64ri -9223372036854775808 $edi = MOV32rr $ebx CALL64pcrel32 @func1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $rax Index: test/DebugInfo/MIR/X86/live-debug-values-spill.mir =================================================================== --- test/DebugInfo/MIR/X86/live-debug-values-spill.mir +++ test/DebugInfo/MIR/X86/live-debug-values-spill.mir @@ -421,11 +421,11 @@ liveins: $r14d, $r15d, $rbp $rdi = LEA64r $rbp, 1, _, -44, _ - DBG_VALUE $rbp, -44, !35, !38, debug-location !60 + DBG_VALUE debug-use $rbp, -44, !35, !38, debug-location !60 $rsi = LEA64r $rbp, 1, _, -60, _ - DBG_VALUE $rbp, -60, !36, !38, debug-location !63 + DBG_VALUE debug-use $rbp, -60, !36, !38, debug-location !63 $rdx = LEA64r $rbp, 1, _, -64, _ - DBG_VALUE $rbp, -64, !37, !38, debug-location !78 + DBG_VALUE debug-use $rbp, -64, !37, !38, debug-location !78 CALL64pcrel32 @set, csr_64, implicit $rsp, implicit $rdi, implicit $rsi, implicit $rdx, implicit-def $rsp, debug-location !79 $eax = MOV32rm $rbp, 1, _, -44, _, debug-location !81 :: (dereferenceable load 4 from %ir.inte, !tbaa !47) DBG_VALUE debug-use $eax, debug-use _, !35, !38, debug-location !60 Index: test/DebugInfo/X86/bbjoin.ll =================================================================== --- test/DebugInfo/X86/bbjoin.ll +++ test/DebugInfo/X86/bbjoin.ll @@ -12,7 +12,7 @@ ; CHECK: ![[X:.*]] = !DILocalVariable(name: "x", ; CHECK: bb.0.entry: ; CHECK: DBG_VALUE 23, debug-use $noreg, ![[X]], -; CHECK: DBG_VALUE $rsp, 0, ![[X]], !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), +; CHECK: DBG_VALUE debug-use $rsp, 0, ![[X]], !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), ; CHECK: bb.1.if.then: ; CHECK: DBG_VALUE 43, debug-use $noreg, ![[X]], ; CHECK: bb.2.if.end: Index: test/DebugInfo/X86/pr34545.ll =================================================================== --- test/DebugInfo/X86/pr34545.ll +++ test/DebugInfo/X86/pr34545.ll @@ -1,13 +1,13 @@ ; RUN: llc -O1 -filetype=asm -mtriple x86_64-unknown-linux-gnu -mcpu=x86-64 -o - %s -stop-after=livedebugvars | FileCheck %s ; CHECK: $eax = MOV32rm -; CHECK: DBG_VALUE $eax +; CHECK: DBG_VALUE debug-use $eax ; CHECK: $eax = SHL32rCL killed renamable $eax -; CHECK: DBG_VALUE $eax -; CHECK: DBG_VALUE $rsp, 0, !{{[0-9]+}}, !DIExpression(DW_OP_constu, 4, DW_OP_minus) -; CHECK: DBG_VALUE $eax +; CHECK: DBG_VALUE debug-use $eax +; CHECK: DBG_VALUE debug-use $rsp, 0, !{{[0-9]+}}, !DIExpression(DW_OP_constu, 4, DW_OP_minus) +; CHECK: DBG_VALUE debug-use $eax ; CHECK: $eax = SHL32rCL killed renamable $eax -; CHECK: DBG_VALUE $eax +; CHECK: DBG_VALUE debug-use $eax ; CHECK: RETQ $eax target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"