[llvm] [Dwarf] Emit `DW_AT_bit_size` for non-byte-sized types (PR #137118)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 12:00:43 PDT 2025
dwblaikie wrote:
> > Could you point me to where you've written up (or write it up here) where we need non-byte sized objects? A C++ `bool` is still byte sized (its `sizeof` is 1) so I wouldn't expect to want/need bit-sized things to implement C++ `bool`... is there something else going on here?
>
> The sequence `DW_OP_LLVM_convert, 1, DW_ATE_unsigned` is generated by `salvageDebugInfo`:
>
> https://github.com/llvm/llvm-project/blob/5717c5f385d3b8f5b395c3013aaba9929a618aa3/llvm/lib/Transforms/Utils/Local.cpp#L2630-L2633
But the size of the actual C++ `bool` variable is one byte. We lost the high bits, so we should probably be describing it as 7 unknown high bits and 1 known low bit. At the LLVM level we probably don't want to embed language-specific knowledge that those high bits are all zero - but a DWARF consumer might have that knowledge & be able to render the value to the user as true/false because it knows the high bits are always all zero in valid code.
https://github.com/llvm/llvm-project/pull/137118
More information about the llvm-commits
mailing list