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

Michael Buch via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 03:28:18 PDT 2025


================
@@ -820,6 +833,22 @@ void DwarfCompileUnit::applyConcreteDbgVariableAttributes(
   }
   if (!DVal->isVariadic()) {
     const DbgValueLocEntry *Entry = DVal->getLocEntries().begin();
+
+    // Helper function to handle boolean constant values with type safety
+    auto addConstantValueWithBooleanNormalization =
----------------
Michael137 wrote:

I guess what's confusing me is:
1. Who is assigning `-1` to indicate `true`?
2. There seem to be two independent changes in this PR:
  * emit `DW_OP_lit` for boolean constants when computing debug values. This seems very reasonable since it makes the DWARF expression simpler (and works regardless of how the true/false values are represented?)
  * Don't emit `DW_OP_constu (-1)` values for booleans. That also seems reasonable, but what I'm curious about where this `-1` comes from? And then, if you do this kind of normalization for booleans here, why not any other place where `DW_AT_const_value` is emitted for booleans? You don't strictly have to but I think we can split these two changes into separate PRs

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


More information about the llvm-commits mailing list