[llvm] [SPIR-V] Emit proper pointer type for OpenCL kernel arguments (PR #67726)
Ilia Diachkov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 06:24:16 PDT 2023
================
@@ -194,23 +194,40 @@ getKernelArgTypeQual(const Function &KernelFunction, unsigned ArgIdx) {
return {};
}
-static Type *getArgType(const Function &F, unsigned ArgIdx) {
+static SPIRVType *getArgSPIRVType(const Function &F, unsigned ArgIdx,
+ SPIRVGlobalRegistry *GR,
+ MachineIRBuilder &MIRBuilder) {
+ // Read argument's access qualifier from metadata or default
+ SPIRV::AccessQualifier::AccessQualifier ArgAccessQual =
+ getArgAccessQual(F, ArgIdx);
+
Type *OriginalArgType = getOriginalFunctionType(F)->getParamType(ArgIdx);
- if (F.getCallingConv() != CallingConv::SPIR_KERNEL ||
- isSpecialOpaqueType(OriginalArgType))
- return OriginalArgType;
+
+ // In case of non-kernel SPIR-V function, use the original IR type.
+ if (F.getCallingConv() != CallingConv::SPIR_KERNEL)
+ return GR->getOrCreateSPIRVType(OriginalArgType, MIRBuilder, ArgAccessQual);
+
+ // Use original type if it is already TargetExtType of a builtin type.
+ if (isSpecialOpaqueType(OriginalArgType))
+ return GR->getOrCreateSPIRVType(OriginalArgType, MIRBuilder, ArgAccessQual);
----------------
iliya-diyachkov wrote:
Should we split the condition if it makes the same call?
https://github.com/llvm/llvm-project/pull/67726
More information about the llvm-commits
mailing list