| Issue |
233484
|
| Summary |
[flang][debug] LICM produces a misleading line table by keeping the source line on hoisted operations
|
| Labels |
|
| Assignees |
jiel-nv
|
| Reporter |
jiel-nv
|
`flang-licm` hoists loop-invariant operations out of a loop but leaves their source location untouched. Since the hoist point precedes the loop, the line table ends up claiming that the body statement begins in the loop setup code. Debuggers then misplace breakpoints set on that statement.
For instance,
```fortran
subroutine scale_add(a, b, c)
implicit none
real :: a(100), b, c
integer :: i
do i = 1, 100
a(i) = a(i) + b * c
end do
end subroutine scale_add
```
```console
$ flang -g -O1 -c licm.f90 -o licm.o
```
A line table dump shows the issue below,
```
Address Line Column Flags
0x00000000 6 5 is_stmt prologue_end <== wrong: the loop body claims the function's first instruction
0x0000000a 0 5
0x00000015 6 5 <== where the body really starts, 0x15 later
0x0000001e 5 3 is_stmt
0x00000027 8 1 is_stmt
0x00000028 8 1 is_stmt end_sequence
```
As a result, gdb may show `<optimized out>` as below,
```console
Breakpoint 1, foo (a=..., b=2, c=3) at licm.f90:6
6 a(i) = a(i) + b * c
(gdb) print i
$1 = <optimized out>
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs