[llvm] [llvm][DebugInfo] Emit 0/1 for constant boolean values (PR #151225)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 05:12:52 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:

Could you elaborate please -- is there an existing convention to that effect for instructions, and does that necessarily extend to debug instructions too? As illustrated in the main thread LLVM inconsistently types variable locations for constant Booleans during optimisation, which creates the need for special-casing. This canonicalization both solves a DWARF-output-flaw, but will also improve variable location coverage by avoiding inconsistent constant-values (variable locations can be spuriously dropped as a result).

(We can cannonicalise from Booleans up to integer-one as in this patch, but it's a lot more difficult to ensure the validity of converting non-false-non-i1 LLVM-IR values down to Boolean -1).

https://github.com/llvm/llvm-project/pull/151225


More information about the llvm-commits mailing list