[flang-commits] [flang] [Flang] Set address space during FIR pointer-like types lowering (PR #69599)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Fri Oct 20 04:47:45 PDT 2023


skatrak wrote:

Thank you @jeanPerier for looking into this and for your suggestions. I focused on the particular issue of fir.alloca lowering, so I didn't realize about all these other spots in FIR lowering where `LLVMPointerType`s can be instantiated.

I like the idea of making the LLVM dialect responsible for this, but I think it currently can't be done without making changes to the `LLVMPointerType`. The issue is that its `addressSpace` parameter is default-valued to 0, so after creation there would be no way of telling whether a pointer was meant to be specifically for address space 0 or if it was supposed to take the data layout's default.

I'm not that familiar with the specifics of address spaces either, but if my concern is right that would mean that LLVM dialect's users must specify the address space of any `LLVMPointerType` instances that are not supposed to go to address space 0, and handle the data layout themselves. I think that the alternative solution of moving the responsibility of checking for the data layout to the LLVM dialect would mean allowing the address space to be optional, so that during translation to LLVM IR we could check for the data layout before falling back to 0 as a last option.

I'm not sure what the right approach here would be, so I'd be interested to hear some opinions.

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


More information about the flang-commits mailing list