diff options
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(); |