forked from OSchip/llvm-project
[InstCombine] Avoid creating mis-sized dbg.values in commonCastTransforms()
This prevents InstCombine from creating mis-sized dbg.values when replacing a sequence of casts with a simpler cast. For example, in: (fptrunc (floor (fpext X))) -> (floorf X) We no longer emit dbg.value(X) (with a 32-bit float operand) to describe (fpext X) (which is a 64-bit float). This was diagnosed by the debugify check added in r335682. llvm-svn: 335696
This commit is contained in:
parent
d13536e9f3
commit
f6c0b41fb7
|
@ -266,10 +266,13 @@ Instruction *InstCombiner::commonCastTransforms(CastInst &CI) {
|
|||
if (Instruction::CastOps NewOpc = isEliminableCastPair(CSrc, &CI)) {
|
||||
// The first cast (CSrc) is eliminable so we need to fix up or replace
|
||||
// the second cast (CI). CSrc will then have a good chance of being dead.
|
||||
auto *Res = CastInst::Create(NewOpc, CSrc->getOperand(0), CI.getType());
|
||||
auto *Ty = CI.getType();
|
||||
auto *Res = CastInst::Create(NewOpc, CSrc->getOperand(0), Ty);
|
||||
// Replace debug users of the eliminable cast by emitting debug values
|
||||
// which refer to the new cast.
|
||||
insertReplacementDbgValues(*CSrc, *Res, *std::next(CI.getIterator()));
|
||||
if (Ty->isIntegerTy() || Ty->isPointerTy())
|
||||
// TODO: Support floats and vectors (see DW_OP_convert, fragment).
|
||||
insertReplacementDbgValues(*CSrc, *Res, *std::next(CI.getIterator()));
|
||||
return Res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck -check-prefix=ALL -check-prefix=DO-SIMPLIFY %s
|
||||
; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck -check-prefix=ALL -check-prefix=DO-SIMPLIFY %s
|
||||
; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck -check-prefix=ALL -check-prefix=DO-SIMPLIFY %s
|
||||
; RUN: opt < %s -enable-debugify -instcombine -S -mtriple "x86_64-pc-win32" 2>&1 | FileCheck -check-prefix=DBG-VALID %s
|
||||
|
||||
declare double @floor(double)
|
||||
declare double @ceil(double)
|
||||
|
@ -685,3 +686,5 @@ define float @test_no_shrink_intrin_fabs_multi_use_fpext(half %C) {
|
|||
%F = fptrunc double %E to float
|
||||
ret float %F
|
||||
}
|
||||
|
||||
; DBG-VALID: CheckModuleDebugify: PASS
|
||||
|
|
Loading…
Reference in New Issue