Aliasing guarantees on memrefs from different memory spaces

I’m just bringing this up for broader attention to see if there are any concerns. The revision linked below is self-explanatory:

It updates the MemRef type’s doc to state that memrefs in different memory spaces
cannot alias with each other. This allows aliasing checks and analysis to be more powerful enforcing useful guarantees and canonicalization.

In LLVM itself, address spaces aren’t mutually disjoint and so pointers from different address spaces can alias. (One can cast across address spaces.) However, the memref type is better not viewed as such a low-level abstraction, and it appears good to restrict things. Note that one can still separately model low-level address spaces and aliasing in the LLVM dialect or similarly “close to the target” dialects – the memref type is deabstracted and expected to not be used in such dialects when such modeling is desired.

1 Like

Thanks for raising this here Uday! I agree with you that it’s ok for the LLVM dialect pointers to be more general than memref conceptually.

That said, don’t widely used accelerators like GPUs have overlapping address spaces already? I’m not at all an expert on these things, but if they do and if that is important to model, it could be useful for memref.

If not, then I’m very +1 on your patch, this would make a whole class of analysis trivial.