[GlobalISel] Emit DBG_VALUE %noreg for non-int/fp constant values.

When a dbg_value has a constant operand that isn't representable in MI,
there isn't much we can do.  Use %noreg (0) for those situations.
This matches the SelectionDAG behavior.

llvm-svn: 297200
This commit is contained in:
Ahmed Bougacha 2017-03-07 20:34:20 +00:00
parent ab50ecb1c7
commit 4826bae8b4
2 changed files with 8 additions and 1 deletions

View File

@ -137,8 +137,13 @@ MachineInstrBuilder MachineIRBuilder::buildConstDbgValue(const Constant &C,
MIB.addCImm(CI); MIB.addCImm(CI);
else else
MIB.addImm(CI->getZExtValue()); MIB.addImm(CI->getZExtValue());
} else } else if (auto *CFP = dyn_cast<ConstantFP>(&C)) {
assert(isa<ConstantFP>(C) && "Unexpected constant dbg value");
MIB.addFPImm(&cast<ConstantFP>(C)); MIB.addFPImm(&cast<ConstantFP>(C));
} else {
// Insert %noreg if we didn't find a usable constant and had to drop it.
MIB.addReg(0U);
}
return MIB.addImm(Offset).addMetadata(Variable).addMetadata(Expr); return MIB.addImm(Offset).addMetadata(Variable).addMetadata(Expr);
} }

View File

@ -26,6 +26,8 @@ define void @debug_value(i32 %in) #0 !dbg !7 {
call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !11, metadata !12), !dbg !13 call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !11, metadata !12), !dbg !13
; CHECK: DBG_VALUE float 1.000000e+00, 0, !11, !12, debug-location !13 ; CHECK: DBG_VALUE float 1.000000e+00, 0, !11, !12, debug-location !13
call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !11, metadata !12), !dbg !13 call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !11, metadata !12), !dbg !13
; CHECK: DBG_VALUE _, 0, !11, !12, debug-location !13
call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !11, metadata !12), !dbg !13
ret void ret void
} }