[flang-commits] [flang] [flang] AliasAnalysis: More formally define and distinguish between data and non-data (PR #91020)
Renaud Kauffmann via flang-commits
flang-commits at lists.llvm.org
Mon May 13 12:33:45 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
----------------
Renaud-K wrote:
We save MustAlias when the starting points match exactly. If we reach the source through an offset calculation we set `approximateSource` and return MayAlias. https://github.com/llvm/llvm-project/commit/c3f060b026a1e7f4676038fffce5ee2bea1292ac
As far, `xnext1#0 <-> xnext2#0`, we could do better and return MustAlias but as @tblah points out in his commit, we do not compare operands used in offset calculation.
https://github.com/llvm/llvm-project/pull/91020
More information about the flang-commits
mailing list