[clang] [clang][CodeGen] Add AS for Globals to SPIR & SPIRV datalayouts (PR #88455)

Arvind Sudarsanam via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 14 17:40:37 PDT 2024


asudarsa wrote:

Thanks @AlexVlx for this change. This should work fine for SPIRV-LLVM-Translator (and SPIR-V backend). Adding @michalpaszkowski for input from SPIR-V backend side. Recently, this restriction on LLVM IR input to our translator was docuemnted:
https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/docs/SPIRVRepresentationInLLVM.rst#global-variables
_"A global variable resides in an address space, and the default address space in LLVM is zero. The SPIR-V storage class represented by the zero LLVM IR address spaces is Function. However, SPIR-V global variable declarations are OpVariable instructions whose Storage Class cannot be Function. This means that global variable declarations must always have an address space specified and that address space cannot be 0."_
So, your change will help to make the LLVM IR more suitable for the translator.

One quick pointer. I did notice a similar commit for the AMDGPU backend - https://reviews.llvm.org/D84345
Here, there are some updates to the llvm/lib/IR/AutoUpgrade.cpp. Do we need similar changes here?

Thanks

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


More information about the cfe-commits mailing list