Open
Description
In Float2Int, the optimization deletes the "root" instructions after converting the float-point operations into integer operations.
llvm-project/llvm/lib/Transforms/Scalar/Float2Int.cpp
Lines 475 to 479 in 0e9571d
However, the optimization only RAUWs the "root" instructions with the converted instructions:
llvm-project/llvm/lib/Transforms/Scalar/Float2Int.cpp
Lines 467 to 469 in 0e9571d
As a result, the debug values of the operands of the RAUWed dead instructions may be lost. Here is an example: https://godbolt.org/z/fqde9nbW4
; after optimization
define i16 @simple1(i8 %a) !dbg !5 {
%1 = zext i8 %a to i32, !dbg !14
#dbg_value(float poison, !9, !DIExpression(), !14)
%t21 = add i32 %1, 1, !dbg !15
#dbg_value(float poison, !11, !DIExpression(), !15)
%2 = trunc i32 %t21 to i16, !dbg !16
#dbg_value(i16 %2, !12, !DIExpression(), !16)
ret i16 %2, !dbg !17
}
So, in this case, should we use SalvageDebugInfo
or replaceAllDbgUses
on these operands?
CC @OCHyams