[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:43 PDT 2024
================
@@ -46,6 +47,56 @@ struct AliasAnalysis {
/// Attributes of the memory source object.
ENUM_CLASS(Attribute, Target, Pointer, IntentIn);
+ // See
+ // https://discourse.llvm.org/t/rfc-distinguish-between-data-and-non-data-in-fir-alias-analysis/78759/1
+ //
+ // It is possible, while following the source of a memory reference through
+ // the use-def chain, to arrive at the same origin, even though the starting
+ // points were known to not alias.
+ //
+ // Example:
+ // clang-format off
+ // fir.global @_QMtopEa : !fir.box<!fir.ptr<!fir.array<?xf32>>>
+ //
+ // func.func @_QPtest() {
+ // %c1 = arith.constant 1 : index
+ // %cst = arith.constant 1.000000e+00 : f32
+ // %0 = fir.address_of(@_QMtopEa) : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ // %1 = fir.declare %0 {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMtopEa"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ // %2 = fir.load %1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>
+ // ...
+ // %5 = fir.array_coor %2 %c1 : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, !fir.shift<1>, index) -> !fir.ref<f32>
+ // fir.store %cst to %5 : !fir.ref<f32>
+ // return
+ // }
+ //
+ // With high level operations, such as fir.array_coor, it is possible to
+ // reach into the data wrapped by the box (the descriptor) therefore when
+ // asking about the memory source of the %5, we are really asking about the
+ // source of the data of box %2.
+ //
+ // When asking about the source of %0 which is the address of the box, we
+ // reach the same source as in the first case: the global @_QMtopEa. Yet one
+ // source refers to the data while the other refers to the address of the box
+ // itself.
+ //
+ // To distinguish between the two, the isData flag has been added, whereby
----------------
jdenny-ornl wrote:
```suggestion
// The isData flag distinguishes between the two, whereby
```
https://github.com/llvm/llvm-project/pull/91020
More information about the flang-commits
mailing list