diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index 7328ea4eed25..85ed9d3ac4d9 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -111,6 +111,8 @@ MachineInstrBuilder MachineIRBuilder::buildConstDbgValue(const Constant &C, MIB.addImm(CI->getZExtValue()); } else if (auto *CFP = dyn_cast(NumericConstant)) { MIB.addFPImm(CFP); + } else if (isa(NumericConstant)) { + MIB.addImm(0); } else { // Insert $noreg if we didn't find a usable constant and had to drop it. MIB.addReg(Register()); diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll b/llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll index 5573378b087d..a024ad8d2057 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll @@ -25,6 +25,8 @@ entry: ret void, !dbg !15 } +@gv = global i32 zeroinitializer + ; CHECK-LABEL: name: debug_value ; CHECK: [[IN:%[0-9]+]]:_(s32) = COPY $w0 define void @debug_value(i32 %in) #0 !dbg !16 { @@ -38,8 +40,10 @@ define void @debug_value(i32 %in) #0 !dbg !16 { call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 ; CHECK: DBG_VALUE float 1.000000e+00, 0, !17, !DIExpression(), debug-location !18 call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 -; CHECK: DBG_VALUE $noreg, 0, !17, !DIExpression(), debug-location !18 +; CHECK: DBG_VALUE 0, 0, !17, !DIExpression(), debug-location !18 call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 +; CHECK: DBG_VALUE $noreg, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32* @gv, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 ; CHECK: DBG_VALUE 42, 0, !17, !DIExpression(), debug-location !18 call void @llvm.dbg.value(metadata i32* inttoptr (i64 42 to i32*), i64 0, metadata !17, metadata !DIExpression()), !dbg !18 ret void