[PATCH] D118183: Fix UB in DwarfExpression::emitLegacyZExt()
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 26 12:47:15 PST 2022
xbolva00 added inline comments.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp:686
+ // A ULEB can encode 7 1-bits per byte.
+ if (FromBits / 7 < 1+1+1+1+1) {
+ // (X & (1 << FromBits - 1))
----------------
JDevlieghere wrote:
> I had some trouble figuring out what the `1+1+1+1+1` was supposed to represent. In case anyone is wondering it's 1 byte per DWARF opcode and 1 byte for the small ULEB128 in the alternative encoding below. Maybe we should make that more clear in the comment or used a named temporary/
>
> Also, should we use `(FromBits+6)/7` to ensure we always round up?
Agree with you. This should be reworked /commented more.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118183/new/
https://reviews.llvm.org/D118183
More information about the llvm-commits
mailing list