[PATCH] D117124: [DWARF][DebugInfo] Fix off-by-one error in size of DW_TAG_base_type types

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 02:03:16 PST 2022


Orlando added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1585
+    // Round up to smallest number of bytes that contains this number of bits.
+    uint64_t NumBytes = (static_cast<uint64_t>(Btr.BitSize) + 7) / 8;
+    addUInt(Die, dwarf::DW_AT_byte_size, None, NumBytes);
----------------
probinson wrote:
> You'd think there would be a convenience macro for this, but I'm not finding one.  I do have a memory that someone started making some changes to remove the hard-coded assumption about 8-bit bytes, but it's vague and unless someone else can come up with an example of doing this differently, it's not a blocker.
I had vague memories about hardcoded 8-bit bytes too. Since you mentioned it, I had a look around in DataLayout but I couldn't find anything that would give me the size of a byte and many of the Datalayout methods appear to assume it's 8 bits. In my rummaging around I did find `divideCeil` at least, which makes this slightly tidier.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117124/new/

https://reviews.llvm.org/D117124



More information about the llvm-commits mailing list