[Util] Refer to [s|z]exts of args when converting dbg.declares (fix PR35400)
authorVedant Kumar <vsk@apple.com>
Sat, 15 Dec 2018 00:03:33 +0000 (00:03 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 15 Dec 2018 00:03:33 +0000 (00:03 +0000)
commit9d1827331f3f9582fa2ed05913ae4301f2604a19
tree0ff3fa53b9f20ffeff192d0f653cafb0674e0b12
parent6d74bd638a85cc17f3d5784e41d3d0162aad787c
[Util] Refer to [s|z]exts of args when converting dbg.declares (fix PR35400)

When converting dbg.declares, if the described value is a [s|z]ext,
refer to the ext directly instead of referring to its operand.

This fixes a narrowing bug (the debugger got the sign of a variable
wrong, see llvm.org/PR35400).

The main reason to refer to the ext's operand was that an optimization
may remove the ext itself, leading to a dropped variable. Now that
InstCombine has been taught to use replaceAllDbgUsesWith (r336451), this
is less of a concern. Other passes can/should adopt this API as needed
to fix dropped variable bugs.

Differential Revision: https://reviews.llvm.org/D51813

llvm-svn: 349214
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/Util/dbg-user-of-aext.ll [moved from llvm/test/Transforms/Util/split-bit-piece.ll with 88% similarity]