diff options
author | Vedant Kumar <vsk@apple.com> | 2018-12-15 00:03:33 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-12-15 00:03:33 +0000 |
commit | 9d1827331f3f9582fa2ed05913ae4301f2604a19 (patch) | |
tree | 0ff3fa53b9f20ffeff192d0f653cafb0674e0b12 /llvm/lib/Transforms | |
parent | 6d74bd638a85cc17f3d5784e41d3d0162aad787c (diff) | |
download | bcm5719-llvm-9d1827331f3f9582fa2ed05913ae4301f2604a19.tar.gz bcm5719-llvm-9d1827331f3f9582fa2ed05913ae4301f2604a19.zip |
[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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index fa0151dbd9f..79343a90a0e 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1297,33 +1297,6 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, return; } - // If an argument is zero extended then use argument directly. The ZExt - // may be zapped by an optimization pass in future. - Argument *ExtendedArg = nullptr; - if (ZExtInst *ZExt = dyn_cast<ZExtInst>(SI->getOperand(0))) - ExtendedArg = dyn_cast<Argument>(ZExt->getOperand(0)); - if (SExtInst *SExt = dyn_cast<SExtInst>(SI->getOperand(0))) - ExtendedArg = dyn_cast<Argument>(SExt->getOperand(0)); - if (ExtendedArg) { - // If this DII was already describing only a fragment of a variable, ensure - // that fragment is appropriately narrowed here. - // But if a fragment wasn't used, describe the value as the original - // argument (rather than the zext or sext) so that it remains described even - // if the sext/zext is optimized away. This widens the variable description, - // leaving it up to the consumer to know how the smaller value may be - // represented in a larger register. - if (auto Fragment = DIExpr->getFragmentInfo()) { - unsigned FragmentOffset = Fragment->OffsetInBits; - SmallVector<uint64_t, 3> Ops(DIExpr->elements_begin(), - DIExpr->elements_end() - 3); - Ops.push_back(dwarf::DW_OP_LLVM_fragment); - Ops.push_back(FragmentOffset); - const DataLayout &DL = DII->getModule()->getDataLayout(); - Ops.push_back(DL.getTypeSizeInBits(ExtendedArg->getType())); - DIExpr = Builder.createExpression(Ops); - } - DV = ExtendedArg; - } if (!LdStHasDebugValue(DIVar, DIExpr, SI)) Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, DII->getDebugLoc(), SI); |