[PATCH] D56587: Fix sign/zero extension in Dwarf expressions.

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 11 08:30:47 PST 2019


bjope added inline comments.


================
Comment at: lib/Transforms/Utils/Local.cpp:1855
+        // Sign extend To to FromBits
+        // (((To >> (ToBits - 1)) * (~0)) << ToBits) | To
+        SmallVector<uint64_t, 11> Ops({dwarf::DW_OP_dup,
----------------
aprantl wrote:
> I haven't had any coffee yet, but shouldn't that be `FromBits` and From ?:
> ```
> 00001110 >> 4-1 * ~0 << 4 | 00001110
>         1       * ~0 << 4 | 00001110 
>         11111111     << 4 | 00001110 
>         11110000          | 00001110
>                      11111110
> ```
This method is replacing one dbg use with another. So "from" is the old value and "to" is the new value. Here we replace a old large value (e.g. i32) by a new smaller value (e.g. i16). So we sign extend from `ToBits` to `FromBits` to convert the new value back into something that represents the old value in the debugger. I think I needed both coffee and lunch to understand that we extend from `To` to `From` here.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56587





More information about the llvm-commits mailing list