[flang-commits] [flang] [flang] Treat visible Cray pointer associations as aliasing for TBAA (PR #221350)

via flang-commits flang-commits at lists.llvm.org
Mon Sep 7 04:41:37 PDT 2026


================
@@ -281,13 +281,14 @@ print *, target
 end
 ```
 
-By default, optimizations assume that Cray pointers do not alias any other
-variables. In the above example, it is assumed that `handle` and `target` do
-not alias, and optimizations will treat them as separate entities.
+By default, optimizations assume that Cray pointers do not alias other
+variables unless the association is visible in the same procedure. In the
+above example, `ptr = loc(target)` causes accesses through `handle` and
+`target` to be treated as potentially aliasing.
----------------
jeanPerier wrote:

The description is not fully accurate, your change is only causing "accesses through `handle` and `target` to be treated as potentially aliasing" after TBAA emission, so not at the MLIR level.

The issue I see with this is that whatever code you are attempting to get to work with flang will break again as far as we start doing more optimizations like load store forwarding at the MLIR level.

If we want to deploy the feature you are describing, I think the more robust would be to do something in lowering where we add TARGET to symbols that appears in such assignment statement so that all FIR passes consider the potential aliasing.

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


More information about the flang-commits mailing list