llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-amdgpu Author: Akimasa Watanuki (Men-cotton) <details> <summary>Changes</summary> Emit the CIR OpenCL kernel argument metadata attribute for kernel functions. Preserve CIR language address-space kinds until lowering and include argument names only when `-cl-kernel-arg-info` is enabled. Depends on #<!-- -->199530. --- Patch is 34.84 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/200581.diff 20 Files Affected: - (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td (+25-6) - (modified) clang/include/clang/CIR/Dialect/IR/CIRAttrs.td (+7-2) - (modified) clang/include/clang/CIR/Dialect/IR/CIRDialect.td (+1) - (modified) clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td (+3-1) - (added) clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td (+46) - (modified) clang/lib/CIR/CodeGen/CIRGenFunction.cpp (+3) - (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+83) - (modified) clang/lib/CIR/CodeGen/CIRGenModule.h (+4) - (added) clang/lib/CIR/Dialect/IR/CIROpenCLAttrs.cpp (+38) - (modified) clang/lib/CIR/Dialect/IR/CIRTypes.cpp (+2) - (modified) clang/lib/CIR/Dialect/IR/CMakeLists.txt (+1) - (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/AMDGPU.cpp (+2) - (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp (+1) - (modified) clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIRV.cpp (+2) - (added) clang/test/CIR/CodeGenOpenCL/kernel-arg-info-single-as.cl (+19) - (added) clang/test/CIR/CodeGenOpenCL/kernel-arg-info.cl (+152) - (added) clang/test/CIR/CodeGenOpenCL/kernel-arg-metadata.cl (+7) - (modified) clang/test/CIR/IR/invalid-addrspace.cir (+1-1) - (added) clang/test/CIR/IR/invalid-opencl-kernel-arg-metadata.cir (+78) - (added) clang/test/CIR/IR/opencl-kernel-arg-metadata.cir (+39) ``````````diff diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td index 2548d464fb07f..3cb21dd2f4fc7 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td @@ -71,15 +71,34 @@ def CIR_TryHandlerAttr // ArrayAttr constraints //===----------------------------------------------------------------------===// -def CIR_IntArrayAttr : TypedArrayAttrBase<CIR_AnyIntAttr, - "integer array attribute">; - -def CIR_IntOrGlobalViewArrayAttr : TypedArrayAttrBase<CIR_AnyIntOrGlobalViewAttr, - "integer or global view array attribute">{ +class CIR_TypedArrayAttrBase<Attr element, string summary> + : TypedArrayAttrBase<element, summary> { string cppType = "::mlir::ArrayAttr"; } -def CIR_TryHandlerArrayAttr : TypedArrayAttrBase<CIR_TryHandlerAttr, +class CIR_TypedArrayAttrOrNullBase<Attr element, string summary> + : CIR_TypedArrayAttrBase<element, summary> { + let predicate = Or<[ + CPred<"!$_self">, + CIR_TypedArrayAttrBase<element, summary>.predicate + ]>; + string defaultValue = "::mlir::ArrayAttr()"; +} + +def CIR_IntArrayAttr : CIR_TypedArrayAttrBase<CIR_AnyIntAttr, + "integer array attribute">; + +def CIR_IntOrGlobalViewArrayAttr + : CIR_TypedArrayAttrBase<CIR_AnyIntOrGlobalViewAttr, + "integer or global view array attribute">; + +def CIR_StringArrayAttr + : CIR_TypedArrayAttrBase<StrAttr, "string array attribute">; + +def CIR_StringArrayAttrOrNull + : CIR_TypedArrayAttrOrNullBase<StrAttr, "string array attribute or null">; + +def CIR_TryHandlerArrayAttr : CIR_TypedArrayAttrBase<CIR_TryHandlerAttr, "catch all or unwind or global view array attribute">; #endif // CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index 4032d8219fff3..0044c5bd1eadb 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -996,6 +996,10 @@ def CIR_LangAddressSpaceAttr : CIR_EnumAttr<CIR_LangAddressSpace, }]; } +def CIR_LangAddressSpaceArrayAttr + : CIR_TypedArrayAttrBase<CIR_LangAddressSpaceAttr, + "language address space array attribute">; + //===----------------------------------------------------------------------===// // TargetAddressSpaceAttr //===----------------------------------------------------------------------===// @@ -1684,9 +1688,10 @@ def CIR_AnnotationAttr : CIR_Attr<"Annotation", "annotation"> { } def CIR_AnnotationArrayAttr - : TypedArrayAttrBase<CIR_AnnotationAttr, - "array of cir.annotation attributes">; + : CIR_TypedArrayAttrBase<CIR_AnnotationAttr, + "array of cir.annotation attributes">; +include "clang/CIR/Dialect/IR/CIROpenCLAttrs.td" include "clang/CIR/Dialect/IR/CIRCUDAAttrs.td" #endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td index aaa7b48262c80..c20af04f97a1a 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDialect.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialect.td @@ -82,6 +82,7 @@ def CIR_Dialect : Dialect { static llvm::StringRef getAMDGPUCodeObjectVersionAttrName() { return "cir.amdhsa_code_object_version"; } static llvm::StringRef getAMDGPUPrintfKindAttrName() { return "cir.amdgpu_printf_kind"; } + static llvm::StringRef getOpenCLKernelArgMetadataAttrName() { return "cir.cl.kernel_arg_metadata"; } void registerAttributes(); void registerTypes(); diff --git a/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td b/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td index 1de6ffdc08d72..cc6f256ddfef4 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td +++ b/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td @@ -43,7 +43,9 @@ def CIR_LangAddressSpace : CIR_I32EnumAttr< I32EnumAttrCase<"OffloadLocal", 2, "offload_local">, I32EnumAttrCase<"OffloadGlobal", 3, "offload_global">, I32EnumAttrCase<"OffloadConstant", 4, "offload_constant">, - I32EnumAttrCase<"OffloadGeneric", 5, "offload_generic"> + I32EnumAttrCase<"OffloadGeneric", 5, "offload_generic">, + I32EnumAttrCase<"OffloadGlobalDevice", 6, "offload_global_device">, + I32EnumAttrCase<"OffloadGlobalHost", 7, "offload_global_host"> ]> { let description = [{ Enumerates language-specific address spaces used by CIR. These represent diff --git a/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td new file mode 100644 index 0000000000000..94b41da4c925d --- /dev/null +++ b/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td @@ -0,0 +1,46 @@ +//===- CIROpenCLAttrs.td - CIR dialect attrs for OpenCL ----*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file declares the CIR dialect attributes for OpenCL. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD +#define CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD + +//===----------------------------------------------------------------------===// +// OpenCLKernelArgMetadataAttr +//===----------------------------------------------------------------------===// + +def CIR_OpenCLKernelArgMetadataAttr + : CIR_Attr<"OpenCLKernelArgMetadata", "cl.kernel_arg_metadata"> { + let summary = "OpenCL kernel argument metadata"; + let description = [{ + Stores the OpenCL kernel argument metadata emitted to LLVM IR as + `kernel_arg_*` metadata. + + All parameters are arrays containing the argument information in source + order. The `name` field is optional and is emitted only when requested by + `-cl-kernel-arg-info`. + }]; + + let parameters = (ins + CIR_LangAddressSpaceArrayAttr:$addr_space, + CIR_StringArrayAttr:$access_qual, + CIR_StringArrayAttr:$type, + CIR_StringArrayAttr:$base_type, + CIR_StringArrayAttr:$type_qual, + CIR_StringArrayAttrOrNull:$name + ); + + let assemblyFormat = "`<` struct(params) `>`"; + let genVerifyDecl = 1; + let canHaveIllegalCXXABIType = 0; +} + +#endif // CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 52e7a9d3de412..e45c93c33381c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -818,6 +818,9 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn, finishFunction(bodyRange.getEnd()); } + if (getLangOpts().OpenCL && funcDecl->hasAttr<DeviceKernelAttr>()) + cgm.emitOpenCLKernelArgMetadata(fn, funcDecl); + eraseEmptyAndUnusedBlocks(fn); return fn; } diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index defa5eb12d136..1c8b58bd32ece 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -3110,6 +3110,89 @@ void CIRGenModule::setCIRFunctionAttributesForDefinition( assert(!cir::MissingFeatures::opFuncColdHotAttr()); } +void CIRGenModule::emitOpenCLKernelArgMetadata(cir::FuncOp func, + const clang::FunctionDecl *fd) { + assert(fd && "expected a kernel function declaration"); + const PrintingPolicy &policy = getASTContext().getPrintingPolicy(); + + SmallVector<mlir::Attribute, 8> addressQuals; + SmallVector<mlir::Attribute, 8> accessQuals; + SmallVector<mlir::Attribute, 8> argTypeNames; + SmallVector<mlir::Attribute, 8> argBaseTypeNames; + SmallVector<mlir::Attribute, 8> argTypeQuals; + SmallVector<mlir::Attribute, 8> argNames; + + for (const ParmVarDecl *param : fd->parameters()) { + argNames.push_back(builder.getStringAttr(param->getName())); + + QualType type = param->getType(); + std::string typeQuals; + + if (type->isImageType() || type->isPipeType()) { + errorNYI(param->getSourceRange(), + "OpenCL kernel argument metadata for image and pipe types"); + return; + } + + accessQuals.push_back(builder.getStringAttr("none")); + + auto getTypeSpelling = [&](QualType paramType) { + std::string typeName = paramType.getUnqualifiedType().getAsString(policy); + + if (paramType.isCanonical()) { + StringRef typeNameRef = typeName; + if (typeNameRef.consume_front("unsigned ")) + return std::string("u") + typeNameRef.str(); + if (typeNameRef.consume_front("signed ")) + return typeNameRef.str(); + } + + return typeName; + }; + + if (type->isPointerType()) { + QualType pointeeType = type->getPointeeType(); + addressQuals.push_back(cir::LangAddressSpaceAttr::get( + &getMLIRContext(), + cir::toCIRLangAddressSpace(pointeeType.getAddressSpace()))); + + argTypeNames.push_back( + builder.getStringAttr(getTypeSpelling(pointeeType) + "*")); + argBaseTypeNames.push_back(builder.getStringAttr( + getTypeSpelling(pointeeType.getCanonicalType()) + "*")); + + if (type.isRestrictQualified()) + typeQuals = "restrict"; + if (pointeeType.isConstQualified() || + pointeeType.getAddressSpace() == LangAS::opencl_constant) + typeQuals += typeQuals.empty() ? "const" : " const"; + if (pointeeType.isVolatileQualified()) + typeQuals += typeQuals.empty() ? "volatile" : " volatile"; + } else { + addressQuals.push_back(cir::LangAddressSpaceAttr::get( + &getMLIRContext(), cir::LangAddressSpace::Default)); + + argTypeNames.push_back(builder.getStringAttr(getTypeSpelling(type))); + argBaseTypeNames.push_back( + builder.getStringAttr(getTypeSpelling(type.getCanonicalType()))); + } + + argTypeQuals.push_back(builder.getStringAttr(typeQuals)); + } + + mlir::ArrayAttr names; + if (getCodeGenOpts().EmitOpenCLArgMetadata) + names = builder.getArrayAttr(argNames); + + mlir::Attribute metadata = cir::OpenCLKernelArgMetadataAttr::get( + func.getContext(), builder.getArrayAttr(addressQuals), + builder.getArrayAttr(accessQuals), builder.getArrayAttr(argTypeNames), + builder.getArrayAttr(argBaseTypeNames), + builder.getArrayAttr(argTypeQuals), names); + func->setAttr(cir::CIRDialect::getOpenCLKernelArgMetadataAttrName(), + metadata); +} + cir::FuncOp CIRGenModule::getOrCreateCIRFunction( StringRef mangledName, mlir::Type funcType, GlobalDecl gd, bool forVTable, bool dontDefer, bool isThunk, ForDefinition_t isForDefinition, diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.h b/clang/lib/CIR/CodeGen/CIRGenModule.h index 38436fa0ea5db..bf7133e1084c5 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.h +++ b/clang/lib/CIR/CodeGen/CIRGenModule.h @@ -644,6 +644,10 @@ class CIRGenModule : public CIRGenTypeCache { void setCIRFunctionAttributesForDefinition(const clang::FunctionDecl *fd, cir::FuncOp f); + /// Generate OpenCL kernel argument metadata for a kernel function. + void emitOpenCLKernelArgMetadata(cir::FuncOp func, + const clang::FunctionDecl *fd); + void emitGlobalDefinition(clang::GlobalDecl gd, mlir::Operation *op = nullptr); void emitGlobalFunctionDefinition(clang::GlobalDecl gd, mlir::Operation *op); diff --git a/clang/lib/CIR/Dialect/IR/CIROpenCLAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIROpenCLAttrs.cpp new file mode 100644 index 0000000000000..fac083c3af7a7 --- /dev/null +++ b/clang/lib/CIR/Dialect/IR/CIROpenCLAttrs.cpp @@ -0,0 +1,38 @@ +//===- CIROpenCLAttrs.cpp - OpenCL specific attributes in CIR -------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines the OpenCL-specific attrs in the CIR dialect. +// +//===----------------------------------------------------------------------===// + +#include "clang/CIR/Dialect/IR/CIRAttrs.h" + +#include "mlir/IR/Attributes.h" +#include "mlir/IR/Diagnostics.h" +#include "llvm/ADT/STLExtras.h" + +using namespace mlir; +using namespace cir; + +//===----------------------------------------------------------------------===// +// OpenCLKernelArgMetadataAttr definitions +//===----------------------------------------------------------------------===// + +LogicalResult OpenCLKernelArgMetadataAttr::verify( + function_ref<InFlightDiagnostic()> emitError, ArrayAttr addrSpaces, + ArrayAttr accessQuals, ArrayAttr types, ArrayAttr baseTypes, + ArrayAttr typeQuals, ArrayAttr argNames) { + if (!llvm::all_of(ArrayRef<ArrayAttr>{addrSpaces, accessQuals, types, + baseTypes, typeQuals, argNames}, + [&](ArrayAttr attr) { + return !attr || attr.size() == addrSpaces.size(); + })) + return emitError() << "all arrays must have the same number of elements"; + + return success(); +} diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index 23c327e81831b..4a7f6e6a15579 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -1069,7 +1069,9 @@ cir::LangAddressSpace cir::toCIRLangAddressSpace(clang::LangAS langAS) { case LangAS::opencl_generic: return LangAddressSpace::OffloadGeneric; case LangAS::opencl_global_device: + return LangAddressSpace::OffloadGlobalDevice; case LangAS::opencl_global_host: + return LangAddressSpace::OffloadGlobalHost; case LangAS::sycl_global: case LangAS::sycl_global_device: case LangAS::sycl_global_host: diff --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt b/clang/lib/CIR/Dialect/IR/CMakeLists.txt index 98575941035f2..c8205ebeabf6c 100644 --- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt +++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt @@ -4,6 +4,7 @@ add_clang_library(MLIRCIR CIRMemorySlot.cpp CIRTypes.cpp CIRDataLayout.cpp + CIROpenCLAttrs.cpp DEPENDS MLIRCIROpsIncGen diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/AMDGPU.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/AMDGPU.cpp index aa396335dc1cb..f4cdc88d60cf4 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/AMDGPU.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/AMDGPU.cpp @@ -25,6 +25,8 @@ constexpr unsigned AMDGPUAddrSpaceMap[] = { llvm::AMDGPUAS::GLOBAL_ADDRESS, // OffloadGlobal llvm::AMDGPUAS::CONSTANT_ADDRESS, // OffloadConstant llvm::AMDGPUAS::FLAT_ADDRESS, // OffloadGeneric + llvm::AMDGPUAS::GLOBAL_ADDRESS, // OffloadGlobalDevice + llvm::AMDGPUAS::GLOBAL_ADDRESS, // OffloadGlobalHost }; class AMDGPUTargetLoweringInfo : public TargetLoweringInfo { diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp index f38d2b8bfa32d..806e3235b6a8e 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp @@ -17,6 +17,7 @@ constexpr unsigned NVPTXAddrSpaceMap[] = { llvm::NVPTXAS::ADDRESS_SPACE_GENERIC, llvm::NVPTXAS::ADDRESS_SPACE_GENERIC, llvm::NVPTXAS::ADDRESS_SPACE_SHARED, llvm::NVPTXAS::ADDRESS_SPACE_GLOBAL, llvm::NVPTXAS::ADDRESS_SPACE_CONST, llvm::NVPTXAS::ADDRESS_SPACE_GENERIC, + llvm::NVPTXAS::ADDRESS_SPACE_GLOBAL, llvm::NVPTXAS::ADDRESS_SPACE_GLOBAL, }; class NVPTXTargetLoweringInfo : public TargetLoweringInfo { diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIRV.cpp b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIRV.cpp index b759acccd1ac6..5367b4c76e2a0 100644 --- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIRV.cpp +++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIRV.cpp @@ -21,6 +21,8 @@ constexpr unsigned SPIRVAddrSpaceMap[] = { 1, // CrossWorkgroup 2, // UniformConstant 4, // Generic + 5, // GlobalDevice + 6, // GlobalHost }; class SPIRVTargetLoweringInfo : public TargetLoweringInfo { diff --git a/clang/test/CIR/CodeGenOpenCL/kernel-arg-info-single-as.cl b/clang/test/CIR/CodeGenOpenCL/kernel-arg-info-single-as.cl new file mode 100644 index 0000000000000..e18a125098f64 --- /dev/null +++ b/clang/test/CIR/CodeGenOpenCL/kernel-arg-info-single-as.cl @@ -0,0 +1,19 @@ +// Test that OpenCL kernel argument metadata preserves semantic address spaces +// even if the target has only one address space like x86_64 does. +// RUN: %clang_cc1 %s -fclangir -cl-std=CL2.0 -triple x86_64-unknown-linux-gnu -emit-cir -o %t.cir +// RUN: FileCheck %s --input-file=%t.cir --check-prefix=CIR + +kernel void spir_addr_space_kernel_args(__global int *G, __constant int *C, + __local int *L) { + *G = *C + *L; +} + +// CIR-LABEL: cir.func{{.*}} @spir_addr_space_kernel_args +// CIR-SAME: cir.cl.kernel_arg_metadata = #cir.cl.kernel_arg_metadata<addr_space = [#cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_constant)>, #cir<lang_address_space(offload_local)>] + +kernel void global_device_host_kernel_args( + __attribute__((opencl_global_device)) int *D, + __attribute__((opencl_global_host)) int *H) {} + +// CIR-LABEL: cir.func{{.*}} @global_device_host_kernel_args +// CIR-SAME: cir.cl.kernel_arg_metadata = #cir.cl.kernel_arg_metadata<addr_space = [#cir<lang_address_space(offload_global_device)>, #cir<lang_address_space(offload_global_host)>] diff --git a/clang/test/CIR/CodeGenOpenCL/kernel-arg-info.cl b/clang/test/CIR/CodeGenOpenCL/kernel-arg-info.cl new file mode 100644 index 0000000000000..7788195157715 --- /dev/null +++ b/clang/test/CIR/CodeGenOpenCL/kernel-arg-info.cl @@ -0,0 +1,152 @@ +// See also clang/test/CodeGenOpenCL/kernel-arg-info.cl. +// RUN: %clang_cc1 %s -fclangir -cl-std=CL2.0 -triple spirv64-unknown-unknown -emit-cir -o %t.cir +// RUN: FileCheck %s --input-file=%t.cir --check-prefix=CIR +// RUN: %clang_cc1 %s -fclangir -cl-std=CL2.0 -triple spirv64-unknown-unknown -emit-cir -cl-kernel-arg-info -o %t.arginfo.cir +// RUN: FileCheck %s --input-file=%t.arginfo.cir --check-prefix=CIR-ARGINFO + +kernel void global_qualifier_kernel_args( + global int *globalintp, global int *restrict globalintrestrictp, + global const int *globalconstintp, + global const int *restrict globalconstintrestrictp, + global const volatile int *globalconstvolatileintp, + global const volatile int *restrict globalconstvolatileintrestrictp, + global volatile int *globalvolatileintp, + global volatile int *restrict globalvolatileintrestrictp) {} + +// CIR-LABEL: cir.func{{.*}} @global_qualifier_kernel_args +// CIR-SAME: cir.cl.kernel_arg_metadata = #cir.cl.kernel_arg_metadata +// CIR-SAME: addr_space = [#cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>, #cir<lang_address_space(offload_global)>] +// CIR-SAME: access_qual = ["none", "none", "none", "none", "none", "none", "none", "none"] +// CIR-SAME: type = ["int*", "int*", "int*", "int*", "int*", "int*", "int*", "int*"] +// CIR-SAME: base_type = ["int*", "int*", "int*", "int*", "int*", "int*", "int*", "int*"] +// CIR-SAME: type_qual = ["", "restrict", "const", "restrict const", "const volatile", "restrict const volatile", "volatile", "restrict volatile"] +// CIR-ARGINFO-LABEL: cir.func{{.*}} @global_qualifier_kernel_args +// CIR-ARGINFO-SAME: cir.cl.kernel_arg_metadata = #cir.cl.kernel_arg_metadata +// CIR-ARGINFO-SAME: addr_space = [#cir<lang_address_spa... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/200581 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
