diff --git a/.pick_status.json b/.pick_status.json index 1c6ebfcb626..fa06bac7828 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1507,7 +1507,7 @@ "description": "clover/llvm: Use llvm::DataLayout::getABITypeAlign with LLVM >= 16", "nominated": false, "nomination_type": null, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/frontends/clover/llvm/codegen/common.cpp b/src/gallium/frontends/clover/llvm/codegen/common.cpp index 6bf15d8f79d..fe5fc768bcd 100644 --- a/src/gallium/frontends/clover/llvm/codegen/common.cpp +++ b/src/gallium/frontends/clover/llvm/codegen/common.cpp @@ -34,6 +34,7 @@ #include #include "llvm/codegen.hpp" +#include "llvm/compat.hpp" #include "llvm/metadata.hpp" #include "CL/cl.h" @@ -197,6 +198,7 @@ namespace { ::llvm::DataLayout dl(&mod); const auto size_type = dl.getSmallestLegalIntType(mod.getContext(), sizeof(cl_uint) * 8); + const unsigned size_align = compat::get_abi_type_alignment(dl, size_type); for (const auto &arg : f.args()) { const auto arg_type = arg.getType(); @@ -208,7 +210,7 @@ namespace { const unsigned arg_api_size = dl.getTypeAllocSize(arg_type); const unsigned target_size = dl.getTypeStoreSize(arg_type); - const unsigned target_align = dl.getABITypeAlignment(arg_type); + const unsigned target_align = compat::get_abi_type_alignment(dl, arg_type); const auto type_name = get_str_argument_metadata(f, arg, "kernel_arg_type"); @@ -229,7 +231,7 @@ namespace { // Image size implicit argument. args.emplace_back(binary::argument::scalar, sizeof(cl_uint), dl.getTypeStoreSize(size_type), - dl.getABITypeAlignment(size_type), + size_align, binary::argument::zero_ext, binary::argument::image_size); @@ -237,7 +239,7 @@ namespace { // Image format implicit argument. args.emplace_back(binary::argument::scalar, sizeof(cl_uint), dl.getTypeStoreSize(size_type), - dl.getABITypeAlignment(size_type), + size_align, binary::argument::zero_ext, binary::argument::image_format); @@ -259,7 +261,8 @@ namespace { args.emplace_back(binary::argument::local, arg_api_size, target_size, - (pointee_type->isVoidTy()) ? 8 : dl.getABITypeAlignment(pointee_type), + (pointee_type->isVoidTy()) ? 8 : + compat::get_abi_type_alignment(dl, pointee_type), binary::argument::zero_ext); } else { // XXX: Correctly handle constant address space. There is no @@ -301,13 +304,13 @@ namespace { // target according to the selected calling convention. args.emplace_back(binary::argument::scalar, sizeof(cl_uint), dl.getTypeStoreSize(size_type), - dl.getABITypeAlignment(size_type), + size_align, binary::argument::zero_ext, binary::argument::grid_dimension); args.emplace_back(binary::argument::scalar, sizeof(cl_uint), dl.getTypeStoreSize(size_type), - dl.getABITypeAlignment(size_type), + size_align, binary::argument::zero_ext, binary::argument::grid_offset); diff --git a/src/gallium/frontends/clover/llvm/compat.hpp b/src/gallium/frontends/clover/llvm/compat.hpp index 7bcf3d6860b..d2acaa8c58b 100644 --- a/src/gallium/frontends/clover/llvm/compat.hpp +++ b/src/gallium/frontends/clover/llvm/compat.hpp @@ -101,6 +101,16 @@ namespace clover { d); } + static inline unsigned + get_abi_type_alignment(::llvm::DataLayout dl, ::llvm::Type *type) + { +#if LLVM_VERSION_MAJOR >= 16 + return dl.getABITypeAlign(type).value(); +#else + return dl.getABITypeAlignment(type); +#endif + } + static inline bool is_scalable_vector(const ::llvm::Type *type) {