[InstCombine] Preserve debug value when simplifying cast-of-select
authorVedant Kumar <vsk@apple.com>
Tue, 17 Jul 2018 18:08:36 +0000 (18:08 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 17 Jul 2018 18:08:36 +0000 (18:08 +0000)
commit9ece8182914f1625d7e02a5d5a8c4ef2766b894a
treefd2c03fafec17881baafedbc5ec7bf92ff68ba19
parentced3fd4736936e1495968841869df66d3364bd9d
[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
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/debuginfo-variables.ll