Issue 147123
Summary [DebugInfo][Float2Int] Erasing the operands of dead instructions without updating debug values
Labels question, debuginfo, llvm:transforms
Assignees
Reporter Apochens
    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

```llvm
; 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-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to