Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][debuginfo] Array with non constant extent is being treated as assumed size array. #98879

Closed
abidh opened this issue Jul 15, 2024 · 3 comments · Fixed by #110686
Closed
Assignees

Comments

@abidh
Copy link
Contributor

abidh commented Jul 15, 2024

The array with explicit shape with non constant extent is being treated as assumed size array. See the following program:

PROGRAM minimal
  integer arr(-2:3)
  arr(:) = 1
  print *, arr
  call change(arr, 6)
contains
  subroutine change(a, n)
    integer :: a(n)
    a(1) = 10
    print *, a
  end subroutine change
end

When stopped in subroutine change, the type of a is shown as follows:

(gdb) ptype a
type = integer (*)
(gdb) p a
$1 = <error reading variable: failed to get range bounds>

With correct debug information, it should be possible to get the extent of this array.

@abidh abidh self-assigned this Jul 15, 2024
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Jul 15, 2024
@EugeneZelenko EugeneZelenko added debuginfo flang:ir and removed flang Flang issues not falling into any other category labels Jul 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 15, 2024

@llvm/issue-subscribers-debuginfo

Author: Abid Qadeer (abidh)

The array with explicit shape with non constant extent is being treated as assumed size array. See the following program:
PROGRAM minimal
  integer arr(-2:3)
  arr(:) = 1
  print *, arr
  call change(arr, 6)
contains
  subroutine change(a, n)
    integer :: a(n)
    a(1) = 10
    print *, a
  end subroutine change
end

When stopped in subroutine change, the type of a is shown as follows:

(gdb) ptype a
type = integer (*)
(gdb) p a
$1 = &lt;error reading variable: failed to get range bounds&gt;

With correct debug information, it should be possible to get the extent of this array.

@llvmbot
Copy link
Member

llvmbot commented Jul 15, 2024

@llvm/issue-subscribers-flang-ir

Author: Abid Qadeer (abidh)

The array with explicit shape with non constant extent is being treated as assumed size array. See the following program:
PROGRAM minimal
  integer arr(-2:3)
  arr(:) = 1
  print *, arr
  call change(arr, 6)
contains
  subroutine change(a, n)
    integer :: a(n)
    a(1) = 10
    print *, a
  end subroutine change
end

When stopped in subroutine change, the type of a is shown as follows:

(gdb) ptype a
type = integer (*)
(gdb) p a
$1 = &lt;error reading variable: failed to get range bounds&gt;

With correct debug information, it should be possible to get the extent of this array.

@pawosm-arm
Copy link
Contributor

One more example exposing the same issue:

program test
  implicit none
  integer, dimension(-2:2, -3:3), target :: storage2d
  integer, dimension(:, :), pointer :: pointer2d

  storage2d = -1
  pointer2d => storage2d(-1:1, -2:2)
  pointer2d = -7
  call automatic2d(5, 7, storage2d)

contains

  subroutine automatic2d(x, y, arr)
    implicit none
    integer :: x
    integer :: y
    integer :: arr(x, y)

    print *, arr
end

end program

With the breakpoint at line 19 (print *, arr), gdb is unable to print the contents of the array when this program was compiled with flang-new (no such problem when compiled with gfortran):

(gdb) print arr
$1 = <error reading variable: failed to get range bounds>

abidh added a commit to abidh/llvm-project that referenced this issue Oct 1, 2024
The debug information generated by flang did not handle the cases where
dimension or lower bounds of the arrays were variable. This PR fixes
this issue. It will help distinguish assumed size arrays from cases
where array size are variable. It also handles the variable lower bounds
for assumed shape arrays.

Fixes llvm#98879.
@abidh abidh closed this as completed in fc4b1a3 Oct 3, 2024
xgupta pushed a commit to xgupta/llvm-project that referenced this issue Oct 4, 2024
…0686)

The debug information generated by flang did not handle the cases where
dimension or lower bounds of the arrays were variable. This PR fixes
this issue. It will help distinguish assumed size arrays from cases
where array size are variable. It also handles the variable lower bounds
for assumed shape arrays.
    
Fixes llvm#98879.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants