flang
flang copied to clipboard
[DebugInfo] Debug support for assumed shape array at higher optimizations
In existing debug info subscript is defined as lowerBound/upperBound/stride, lowerBound is constant and upperBound is DIVariable and stride is taken from descriptor. At higher optimizations DIVariable can be optimized out, we should use count (from descriptor) in place of upperBound. Descriptor being paramter gives better reliability at higher optimization levels. Below program now shows better debugging with -O2 Inside fun, array1 can be seen.
subroutine fun (array1, array2)
integer :: array1 (:, :)
real :: array2 (:, :, :)
array1(:,:) = 5
array1(1, 1) = 30
array2(:,:,:) = 6
array2(:,:,:) = 3
array2(1,1,1) = 30
array2(3,3,3) = 90
end subroutine
program vla_sub
interface
subroutine fun (array1, array2)
integer :: array1 (:, :)
real :: array2 (:, :, :)
end subroutine
end interface
integer :: sub_arr1(42, 42)
real :: sub_arr2(42, 42, 42)
sub_arr1(:,:) = 1
sub_arr2(:,:,:) = 2
call fun(sub_arr1, sub_arr2)
call fun(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
end program vla_sub
Before fix
Reading symbols from vla-sub-short.O2...
(gdb) b fun
Breakpoint 1 at 0x201c4d: file vla-sub-short.f90, line 5.
(gdb) r
Starting program: vla-sub-short.O2.old
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, fun (array1=<error reading variable: failed to get range bounds>, array2=<error reading variable: failed to get range bounds>) at vla-sub-short.f90:5
5 array1(:,:) = 5
(gdb) p array1
failed to get range bounds
After fix
Breakpoint 2, fun (array1=..., array2=<error reading variable: value requires 296352 bytes, which is more than max-value-size>) at vla-sub-short.f90:5
5 array1(:,:) = 5
(gdb) p array1
$1 = ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...) ...)
Please note that https://github.com/flang-compiler/classic-flang-llvm-project/pull/75 and https://github.com/flang-compiler/classic-flang-llvm-project/pull/82 are dependency for it.
The CI is fixed. Please rebase to run CI.
@alokkrsharma can you fix the CI failure?
/home/runner/work/flang/flang/tools/flang2/flang2exe/lldebug.cpp:3247:56: error: implicit conversion of NULL constant to 'LL_MDRef' (aka 'unsigned int') [-Werror,-Wnull-conversion]
lldbg_create_subrange_mdnode(db, NULL, lbv, ubv, st);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~
0
```
Hi @kiranchandramohan , all the tests pass except on ARM, looks like on ARM, LLVM picked is not latest (does not have https://github.com/flang-compiler/classic-flang-llvm-project/pull/75), can you please help me in this ?
I will have a look. We have to move testing to 13x and stop supporting 11x, 12x.
Hi @bryanpkc @kiranchandramohan, please review/approve this.
Please squash the commits before merging. Thanks!
Hi @kiranchandramohan , do you have any comment on this ?
Thanks @bryanpkc and @pawosm-arm .