summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 9f297b0aab0..aa86dddf04d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -268,17 +268,12 @@ Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
// the second cast (CI). CSrc will then have a good chance of being dead.
auto *Res = CastInst::Create(NewOpc, CSrc->getOperand(0), CI.getType());
- // If the eliminable cast has debug users, insert a debug value after the
- // cast pointing to the new Value.
- SmallVector<DbgInfoIntrinsic *, 1> CSrcDbgInsts;
- findDbgUsers(CSrcDbgInsts, CSrc);
- if (CSrcDbgInsts.size()) {
- DIBuilder DIB(*CI.getModule());
- for (auto *DII : CSrcDbgInsts)
- DIB.insertDbgValueIntrinsic(
- Res, DII->getVariable(), DII->getExpression(),
- DII->getDebugLoc().get(), &*std::next(CI.getIterator()));
- }
+ // Replace debug users of the eliminable cast by emitting debug values
+ // which refer to the new cast.
+ insertReplacementDbgValues(
+ *CSrc, *Res, *std::next(CI.getIterator()),
+ [](DbgInfoIntrinsic &OldDII) { return OldDII.getExpression(); });
+
return Res;
}
}
OpenPOWER on IntegriCloud