[llvm] [DWARF] Emit 0/1 for constant boolean values (PR #151225)
Laxman Sole via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 13:26:05 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 =
----------------
laxmansole wrote:
>Who is assigning -1 to indicate true?
https://github.com/llvm/llvm-project/blob/085d0b001674944613f61a143060350f138859e3/llvm/include/llvm/CodeGen/TargetLowering.h#L236-L241
There is a target-dependent `setBooleanContents`.
While creating `#DBG_VALUE`, the `true/1` gets signed extednded to 0xffffffffffffffff i.e. -1(Line 736 below)
https://github.com/llvm/llvm-project/blob/5886a276ed24c2cd936e602441365bb0bbe5ef40/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp#L731-L749
>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?
I checked all the call sites for `addConstantValue` and found that this is the most relevant one. Alternatively, as you suggested, I could add this normalization to `addConstantValue`, but we don't have `DIType` in all overloaded functions.
>I think we can split these two changes into separate PRs
Sure. Let me spilt these into two separate PRs- current one for the changes in DwarfCompileUnit.cpp and another one for the changes to emit `DW_OP_lit0/1` for booleans.
https://github.com/llvm/llvm-project/pull/151225
More information about the llvm-commits
mailing list