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

VariablesAccessInfo (dependence analysis) does not handle symbols with UNKNOWN access. #2863

Open
arporter opened this issue Jan 21, 2025 · 3 comments

Comments

@arporter
Copy link
Member

In #2825 we realised that although we have AccessType.UNKNOWN, this is never referenced by VariablesAccessInfo. This is dangerous as it means the dependence analysis ignores symbols with this type of access whereas, we should handle them as "worst case" (whatever that happens to be).

@arporter
Copy link
Member Author

In addition, if a CodeBlock contains an intrinsic function call such as sqrt(c) then fparser assumes that sqrt(c) is a Fortran intrinsic (since it matches the signature) and, since we don't check for those, we don't report it. If we have a call to a particular routine then the name of that routine is identified as having an access but, in common with all other signatures in a CodeBlock, it is given READWRITE. Since this is, after all, a CodeBlock, we may just have to live with these limitations and document them.

@arporter
Copy link
Member Author

See also #2825 (comment)

@arporter
Copy link
Member Author

arporter commented Jan 22, 2025

The test for this functionality is in psyir/nodes/codeblock_test.py::test_codeblock_ref_accesses and contains:

def test_codeblock_ref_accesses(parser):
    '''Test that the reference_accesses() method works as expected.

    TODO #2863 - accesses within a CodeBlock should really be marked as
    AccessType.UNKNOWN but are currently always READWRITE. Also, calls to
    Fortran intrinsics are not captured.

    '''
    vai = VariablesAccessInfo()
    reader = FortranStringReader('''
    subroutine mytest
      that_is_true = .TRUE._bool_kind
      hello_str = char_kind_"hello"
      my_cmplx = (1.0_c_def, 1.0_b_def)
      myloop: DO i = 1, 10_i_def
        a = b + sqrt(c) + 1.0_r_def
        myifblock: IF(this_is_true)THEN
          EXIT myloop
        ELSE IF(that_is_true)THEN myifblock
          call my_routine()
          write(*,*) "Bye"
        ELSE myifblock
          write(*,*) "hello"
        END IF myifblock
      END DO myloop
    end subroutine mytest''')
    prog = parser(reader)
    block = CodeBlock(prog.children, CodeBlock.Structure.STATEMENT)
    block.reference_accesses(vai)
    all_sigs = vai.all_signatures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant