[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 09:36:28 PST 2019


bjope added a comment.

In D56587#1354394 <https://reviews.llvm.org/D56587#1354394>, @vsk wrote:

> Thanks for the patch.
>
> t’s not obvious to me from skimming what the bug is with sign extension expressions. Could you describe what goes wrong, and maybe share a small program which shows the debugger behaving incorrectly?


For the signed case the old DIExpression calculated

  (signbit * -1) | x

which always resulted in -1 if the sign bit was set and x if the sign bit was unset. So the problem was that we modified the low bits when doing the OR.

What we really want to do is to copy the sign bit into the extended bits, hence the addition of the DW_OP_shl to get

  ((signbit * -1)  << "number of bits to extend from") | x


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