[flang-commits] [flang] [Flang] - Fix AliasAnalysis to preserve Allocate source kind through box loads (PR #187152)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 18 07:12:21 PDT 2026


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

This is in line with what is done just above and introduced [here](https://github.com/llvm/llvm-project/commit/eb8ffd617a06d16d5e0928dd346b9ed2380c8fec).

Personally not a big fan that we are doing this instead on relying on some data analysis to understand what is inside the descriptor. From an IR point of view, nothing prevents the address that is being placed inside a box allocated on the stack to not be the result of an alloca and allocmem (for instance this is done when lowering `x(1:20) = x(11:30)` and placing the runtime assign call, even if x is a global). This is also not accurate for POINTER descriptor in general where the descriptor may be allocated on the stack and pointing in global memory.

This probably works OK because the cases where the descriptor are allocated and pointing to something else than locally allocated memory is limited to some rare cases around runtime interface and POINTERs, where the attribute is propagated and used before the source kind in aliasing determination. But if we start having passes that do reg to mem for one reason or the other, this may bite us back.

So I do want to block this patch because this is already done and is valid with your use case, but I think we will need to find another way to reason about indirect source kind to keep the IR easy to transform.

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


More information about the flang-commits mailing list