diff options
author | Vedant Kumar <vsk@apple.com> | 2018-07-17 18:08:36 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-07-17 18:08:36 +0000 |
commit | 9ece8182914f1625d7e02a5d5a8c4ef2766b894a (patch) | |
tree | fd2c03fafec17881baafedbc5ec7bf92ff68ba19 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | |
parent | ced3fd4736936e1495968841869df66d3364bd9d (diff) | |
download | bcm5719-llvm-9ece8182914f1625d7e02a5d5a8c4ef2766b894a.tar.gz bcm5719-llvm-9ece8182914f1625d7e02a5d5a8c4ef2766b894a.zip |
[InstCombine] Preserve debug value when simplifying cast-of-select
InstCombine has a cast transform that matches a cast-of-select:
Orig = cast (Src = select Cond TV FV)
And tries to replace it with a select which has the cast folded in:
NewSel = select Cond (cast TV) (cast FV)
The combiner does RAUW(Orig, NewSel), so any debug values for Orig would
survive the transform. But debug values for Src would be lost.
This patch teaches InstCombine to replace all debug uses of Src with
NewSel (taking care of doing any necessary DIExpression rewriting).
Differential Revision: https://reviews.llvm.org/D49270
llvm-svn: 337310
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 481e40612c3..e8ea7396a96 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -282,8 +282,10 @@ Instruction *InstCombiner::commonCastTransforms(CastInst &CI) { // condition may inhibit other folds and lead to worse codegen. auto *Cmp = dyn_cast<CmpInst>(Sel->getCondition()); if (!Cmp || Cmp->getOperand(0)->getType() != Sel->getType()) - if (Instruction *NV = FoldOpIntoSelect(CI, Sel)) + if (Instruction *NV = FoldOpIntoSelect(CI, Sel)) { + replaceAllDbgUsesWith(*Sel, *NV, CI, DT); return NV; + } } // If we are casting a PHI, then fold the cast into the PHI. |