diff options
author | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-07-04 09:55:46 +0000 |
---|---|---|
committer | Anastasis Grammenos <anastasis.gramm2@gmail.com> | 2018-07-04 09:55:46 +0000 |
commit | 509d79789f1206dd8170f737d34f3cf5cc6076ac (patch) | |
tree | 9e48e7c2b5e308874af8382333c4508c379532ba /llvm/lib | |
parent | d68f25568645ad56b989d6825bdef63d9c21c0c5 (diff) | |
download | bcm5719-llvm-509d79789f1206dd8170f737d34f3cf5cc6076ac.tar.gz bcm5719-llvm-509d79789f1206dd8170f737d34f3cf5cc6076ac.zip |
[DebugInfo][InstCombine] Preserve DI after combining zext
When zext is EvaluatedInDifferentType, InstCombine
drops the dbg.value intrinsic. This patch tries to
preserve said DI, by inserting the zext's old DI in the
resulting instruction. (Only for integer type for now)
Differential Revision: https://reviews.llvm.org/D48331
llvm-svn: 336254
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 9f049ac9feb..06d8bc3349d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1079,6 +1079,17 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) { Value *Res = EvaluateInDifferentType(Src, DestTy, false); assert(Res->getType() == DestTy); + // When DestTy is integer, try to preserve any debug values referring + // to the zext being replaced. + // TODO: This should work for vectors as well, possibly via the use + // of DWARF fragments. + if (DestTy->isIntegerTy()) { + insertReplacementDbgValues( + *Src, *Res, CI, [](DbgInfoIntrinsic &OldDII) -> DIExpression * { + return OldDII.getExpression(); + }); + } + uint32_t SrcBitsKept = SrcTy->getScalarSizeInBits()-BitsToClear; uint32_t DestBitSize = DestTy->getScalarSizeInBits(); |