[PATCH] D118183: Fix UB in DwarfExpression::emitLegacyZExt()

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 16:20:26 PST 2022


JDevlieghere 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))
----------------
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? 


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