[flang-commits] [flang] [flang] Support fir.pack_array in FIR alias analysis. (PR #131946)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 19 07:28:14 PDT 2025


jeanPerier wrote:

> I still wonder if this should be modeled as a new temporary allocation (like fir.allocmem or fir.alloca).

The problem is that there may or may not be a copy at runtime (the result of the operation may be the original memory if it was already contiguous or did not met the other repacking runtime conditions).

So `MayAlias` with the original input is the most accurate answer that can be given I think. Looking at it another way, it is true to say:
- everything that must or may alias with the fir.repack input may alias with the output
- everything that is known to not alias with the input of fir.repack is known to not alias with the output.

@vzakhari, I think the `approximateSource` field should be set to avoid `MustAlias` to be returned when comparing the output and input and weird things happening from the fact that they may not be the same thing (I cannot think of anything, but a crazy optimization could maybe assume it does not have address offsets if the base is an exact alias of some already computed offset, like doing CSE of hlfir.designate using aliasing).

@Renaud-K, can you confirm this is a correct usage of the `approximateSource` field?

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


More information about the flang-commits mailing list