PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Improve and use whole routine reference_accesses

Open sergisiso opened this issue 1 year ago • 3 comments

Some transformations have ad-hoc implementations to find all the symbols "used" in a routine, e.g. the two inline transformations (src/psyclone/domain/common/transformations/kernel_module_inline_trans.py line 184) and (src/psyclone/psyir/transformations/inline_trans.py line 678) and maybe others.

These are very error-prone and I wanted to centralise this logic in a utility, but then I realize that "reference_accesses" is probably already what we want, but there is no specialisation of it for routines/containers/scoping_nodes yet.

What refence access for a whole routine should check is, in addition to check the reference_access of the children:

  • ScopingNodes should report on all its declarations.
  • ScopingNodes should report on all its declaration initial values.
  • ScopingNodes should report on all its declaration shapes.
  • ScopingNodes should report on all its datatype declaration initial values.
  • Literal should report on its "literal.datatype.precision"
  • Caller should report on its caller.routine
  • Codeblocks should report on the symbols listed in cblock.get_symbol_names

Then we could replace the ad-hoc implementation on both inline transformations.

Other requirements for this are that:

  • There are situations like #2314 when we need smaller granularity than ScopingNode reference access of symbols touched in the symbol declaration. So maybe the symbol needs to provide this and ScopingNode just request it for the relevant symbols.
  • Some "references" are just touched at compile-time/static which is something different than a READ dependency. I see that the references_access options allow for a "COLLECT-ARRAY-SHAPE-READS" already, but maybe we need something more generic for static reads.

sergisiso avatar Aug 16 '23 10:08 sergisiso