| Issue |
185432
|
| Summary |
[flang][debug] debug info for procedure arguments is not accessible during whole procedure lifetime
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
jeanPerier
|
Debug info for procedure arguments may be unvalidated before the procedure lifetime leading to`<optimized out>` answer after the first few lines inside the procedures even at O0.
I think this is because dbg.declare emitted for procedure arguments are using the argument register as the base address (of the data or descriptor), and LLVM will not try to extend the lifetime of those registers just because they are used in a dbg.declare. So they will typically be invalidated by the first call inside the procedures that is using those passing registers.
Reproducer:
In the code below, it is possible to inquire about `nvar` in the first two lines of `foo`, but after the call to something, the register is invalidated and later query fails with `<optimized out>` . This is not the case at O0 with other Fortran compilers like gfortran, or ifx (nvfortran/classic flang seem to have the issue) and is likely pretty inconvenient for users trying to debug programs.
```
subroutine foo(nvar)
integer :: nvar
integer :: jvar = 2
call something(jvar)
print *, "hello"
end subroutine
subroutine something(n)
integer :: n
print *, n
end subroutine
call foo(1)
end
```
```
flang -g -O0 repro.f90
gdb --quiet -ex "set confirm off" -ex "b 4" -ex "r" -ex "p nvar" -ex "n" -ex "p nvar" -ex "q" ./a.out
```
```
Breakpoint 1, foo (nvar=1) at repro.f90:4
4 call something(jvar)
$1 = 1
2
5 print *, "hello"
$2 = <optimized out>
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs