[flang-commits] [flang] [flang] AliasAnalysis: More formally define and distinguish between data and non-data (PR #91020)

Joel E. Denny via flang-commits flang-commits at lists.llvm.org
Fri May 10 16:08:41 PDT 2024


================
@@ -0,0 +1,51 @@
+// RUN: fir-opt %s -pass-pipeline='builtin.module(func.func(test-fir-alias-analysis))' 2>&1 | FileCheck %s
+
+
+// module m
+// type t
+//  type(t), pointer :: next
+//  integer :: i
+// end type
+// contains
+// subroutine foo(x, y)
+//   type(t) :: x, y
+//   integer :: i1, i2
+//   i1 = x%next%i
+//   x = y
+//   i2 = x%next%i
+// end subroutine
+// end module
+
+// CHECK-LABEL: Testing : "_QMmPfoo"
+// TODO: x and y do not alias
+// CHECK-DAG: x#0 <-> y#0: MayAlias
+// CHECK-DAG: y#0 <-> xnext1#0: MayAlias
+// CHECK-DAG: y#0 <-> xnext2#0: MayAlias
+
+// These however do alias
+// CHECK-DAG: x#0 <-> xnext1#0: MayAlias
+// CHECK-DAG: x#0 <-> xnext2#0: MayAlias
+// CHECK-DAG: xnext1#0 <-> xnext2#0: MayAlias
----------------
jdenny-ornl wrote:

Could you add a brief explanation of why these alias?  I get it from Jean's earlier example, but it seems subtle enough to be worthwhile to document here.

Also, wouldn't MustAlias be better in all three cases, and can we document that here?  That is, for the duration of a call to `foo`, the address of `x` or *of* its `next` pointer cannot change, right?  Thus, `xnext1` and `xnext2` must be the same (even if the loads from them might produce different addresses).

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


More information about the flang-commits mailing list