[flang-commits] [flang] [flang][AliasAnalysis] Cray pointers/pointees might alias with anything (PR #170900)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Dec 5 13:06:14 PST 2025


vzakhari wrote:

Thank you, Tom.  This looks conservatively correct to me, though I am worried if this may cause performance regressions in some apps.  Do you think we can enable this only under an options, e.g. `-funsafe-cray-pointers` or something like this?

This implementation may lose to what gfortran does performance-wise (https://gcc.gnu.org/onlinedocs/gfortran/Cray-pointers.html). They say:
```
Cray pointers work correctly when there is no aliasing (i.e., when they are used to access a dynamically allocated block of memory), and also in any routine where a pointee is used, but any variable with which it shares storage is not used. Code that violates these rules may not run as the user intends. This is not a bug in the optimizer; any code that violates the aliasing rules is invalid. (Note that this is not unique to GNU Fortran; any Fortran compiler that supports Cray pointers “incorrectly” optimizes code with invalid aliasing.)
```

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


More information about the flang-commits mailing list