[DebugInfo][Float2Int] Erasing the operands of dead instructions without updating debug values
In Float2Int, the optimization deletes the "root" instructions after converting the float-point operations into integer operations.
https://github.com/llvm/llvm-project/blob/0e9571df982fb0527cac2c6a6d21ff502f5d4668/llvm/lib/Transforms/Scalar/Float2Int.cpp#L475-L479
However, the optimization only RAUWs the "root" instructions with the converted instructions:
https://github.com/llvm/llvm-project/blob/0e9571df982fb0527cac2c6a6d21ff502f5d4668/llvm/lib/Transforms/Scalar/Float2Int.cpp#L467-L469
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
@llvm/issue-subscribers-debuginfo
Author: Shan Huang (Apochens)
https://github.com/llvm/llvm-project/blob/0e9571df982fb0527cac2c6a6d21ff502f5d4668/llvm/lib/Transforms/Scalar/Float2Int.cpp#L475-L479
However, the optimization only RAUWs the "root" instructions with the converted instructions:
https://github.com/llvm/llvm-project/blob/0e9571df982fb0527cac2c6a6d21ff502f5d4668/llvm/lib/Transforms/Scalar/Float2Int.cpp#L467-L469
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
Hi @Apochens ,
I like to work on this Transforms module since there is no good first issue, let me work and learn. I'm going to assign it.
@Apochens , how can I ask for the commit access, earlier I had but something changed Do I need to mail anyone?
@Apochens , how can I ask for the commit access, earlier I had but something changed Do I need to mail anyone?
You can request commit access according to this doc. By the way, this issue is not confirmed right now. So, it may not be suitable for you.
@Apochens , Thanks for the clarification, once this issue gets accepted then only I will procced for the fix.
Sorry for the slow response on this. I think your analysis looks right @Apochens, it does look like we needlessly drop variable location coverage here. Thanks for the report and details.