[llvm] [llvm][DebugInfo] Emit 0/1 for constant boolean values (PR #151225)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 15 07:25:55 PDT 2025
================
@@ -733,6 +733,8 @@ MachineOperand GetMOForConstDbgOp(const SDDbgOperand &Op) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
if (CI->getBitWidth() > 64)
return MachineOperand::CreateCImm(CI);
+ if (CI->getBitWidth() == 1)
+ return MachineOperand::CreateImm(CI->getZExtValue());
----------------
jmorse wrote:
IMO isel is the right place to put this today (ideally in a year this would all be place in a non-instruction format). It can't be earlier because LLVM-IR transforms will continue to mutate the type of operands to dbg.values. If it's later than isel, it'd need to be in three places (LiveDebugValues, location-list builder, DWARF emitter) so that identical-booleans can be recognised as such and have location-ranges merged (or at least, not conflict and become "optimised out"), which is what we risk with a de-normalised boolean-true. Plus: isel is the natural place to normalise when we reach a non-instruction debug-info format in MIR.
Again, I'm not saying breaking convention here isn't a bad thing, IMO it's the least worst of several normalisation options.
https://github.com/llvm/llvm-project/pull/151225
More information about the llvm-commits
mailing list