[flang-commits] [flang] [flang] introduce fir.copy to avoid load store of aggregates (PR #130289)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Fri Mar 7 10:24:03 PST 2025


https://github.com/tblah approved this pull request.

LGTM with Kiran's comment

As for TBAA, it is difficult to compare it to the fabricator diff you mentioned because we don't really use tbaa in the way it was intended. TBAA is supposed to say that different types can't alias e.g. "loads of integers don't overlap with loads of floats".

The property we use to implement Fortran aliasing rules is that with tags arranged in a tree structure, parents alias with children, but siblings to not alias. Tags from trees with different roots are assumed to alias.

>From what I remember, the tree looks something like this

```
root (unique per function and scope)
- any access
   - data
     - global data
         - global a
         - global b
     - locally allocated data
       - local alloca a
       - local alloca b
     - dummy arg data
       - dummy arg a
       - dummy arg b
     - direct data
  - descriptor member
```

I think the best we can do here would be to find the common parent of the tag given to each argument. For example, if copying one dummy argument to another then this should be tagged as an argument because it could alias with any dummy argument but not a global. If copying a local allocation to a global variable then we would have to make it alias with any other data access (so it would still not alias with descriptor accesses).

To be clear I mean tagging as that parent node, not as a child of it.

https://github.com/llvm/llvm-project/pull/130289


More information about the flang-commits mailing list