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

[DebugInfo] Support for non-contiguous assumed shape array #926

Closed
wants to merge 7 commits into from

Commits on Nov 18, 2020

  1. flang gen-exec doesnt show assumed shape array in debugger

    Note: This modification makes use of recent upgrade to DISubrange
        https://reviews.llvm.org/rGd20bf5a7258d4b6a7f017a81b125275dac1aa166
    
    Currently flang generates 0 sized DISubrange metadata for assumed sahpe arrays.
    
    ---------
    test case
    ---------
    subroutine sub(assume,n1,n2)
      dimension assume(n1,n2)
    end subroutine sub
    -------
    LLVM IR
    -------
    !29 = !DILocalVariable(name: "assume", arg: 1, scope: !26, file: !3, type: !30)
    !30 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, align: 32, elements: !31)
    !31 = !{!32, !32}
    !32 = !DISubrange(count: 0, lowerBound: 1)
    -------
    This is fixed by upgrading DISubrange as it is upgraded in LLVM to be able to
    dump proper DISubrange for assumed shape array.
    -------
    !29 = !DILocalVariable(name: "assume", arg: 1, scope: !26, file: !3, type: !30)
    !30 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, align: 32, elements: !31)
    !31 = !{!32, !36}
    !32 = !DISubrange(lowerBound: 1, upperBound: !33)
    !33 = distinct !DILocalVariable(scope: !34, file: !3, type: !35, flags: DIFlagArtificial)
    !36 = !DISubrange(lowerBound: 1, upperBound: !37)
    !37 = distinct !DILocalVariable(scope: !34, file: !3, type: !35, flags: DIFlagArtificial)
    -------
    alokkrsharma committed Nov 18, 2020
    Configuration menu
    Copy the full SHA
    6d930b7 View commit details
    Browse the repository at this point in the history
  2. Added test case.

    alokkrsharma committed Nov 18, 2020
    Configuration menu
    Copy the full SHA
    ae08c5f View commit details
    Browse the repository at this point in the history
  3. Some minor cleanup.

    alokkrsharma committed Nov 18, 2020
    Configuration menu
    Copy the full SHA
    7eaf80b View commit details
    Browse the repository at this point in the history
  4. [DebugInfo] flang gen-exec does not print pointer/allocatable array i…

    …n debugger
    
    Note: This modification makes use of recent upgrade to DISubrange
    https://reviews.llvm.org/rGd20bf5a7258d4b6a7f017a81b125275dac1aa166
    
    Now, below testcase gives desired results with debugger.
    --------------
    program main
      integer, allocatable  :: arr(:)
      allocate (arr(2:10))
      arr(3) = 9
    end program main
    --------------
    (gdb) pt arr
    type = integer (2:10)
    (gdb) p arr
    $1 = (0, 9, 0, 0, 0, 0, 0, 0, 0)
    --------------
    And below case works as well
    --------------
    program main
    type dt
      integer :: var1
      integer :: var2
      integer, allocatable :: arr1 (:,:)
      integer :: var3
    end type dt
    type(dt) :: dvar1
    dvar1%var1 = 21
    dvar1%var2 = 22
    dvar1%var3 = 23
    allocate (dvar1%arr1(2:9, 3:11))
    dvar1%arr1(5,4) = 11
    end program main
    --------------
    (gdb) pt dvar1
    type = Type dt
    integer :: var1
    integer :: var2
    integer :: arr1(2:9,3:11)
    integer :: var3
    End Type dt
    (gdb) p dvar1%arr1
    $2 = (( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 11, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0, 0, 0) )
    ---------------
    alokkrsharma committed Nov 18, 2020
    Configuration menu
    Copy the full SHA
    7ccd2a9 View commit details
    Browse the repository at this point in the history
  5. flang gen-exec does not generate DW_AT_associated or DW_AT_allocated

        This patch makes use of commited llvm patch
          [DebugInfo] Support for DW_AT_associated and DW_AT_allocated.
          https://reviews.llvm.org/rG2d10258a31a6d05368dfd4442c4aaa7b54614f1e
    
        This fix is needed for allocatable/pointer arrays.
    
        for pointer array (before allocation/association)
        Before fix
        ------
        (gdb) pt ptr
        type = integer (140737345375288:140737354129776)
        (gdb) p ptr
        value requires 35017956 bytes, which is more than max-value-size
        ------
        After fix
        ------
        (gdb) pt ptr
        type = integer (:)
        (gdb) p ptr
        $1 = <not associated>
        ------
        for allocatable array (before allocation)
        Before fix
        ------
        (gdb) pt arr
        type = integer (140737345375288:140737354129776)
        (gdb) p arr
        value requires 35017956 bytes, which is more than max-value-size
        ------
        After fix
        ------
        (gdb) pt arr
        type = integer, allocatable (:)
        (gdb) p arr
        $1 = <not allocated>
        ------
    
    Testing:
        - check-flang
    alokkrsharma committed Nov 18, 2020
    Configuration menu
    Copy the full SHA
    c37f299 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    53eaeb3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    1768076 View commit details
    Browse the repository at this point in the history