From 4ee15720087d0b76423581aef14a98682c42558f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michel=20D=C3=A4nzer?= Date: Wed, 26 Apr 2023 09:30:05 +0200 Subject: [PATCH] clover/llvm: Use llvm::DataLayout::getABITypeAlign with LLVM >= 16 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit llvm::DataLayout::getABITypeAlignment is deprecated: ../src/gallium/frontends/clover/llvm/codegen/common.cpp: In function ‘std::vector {anonymous}::make_kernel_args(const llvm::Module&, const std::string&, const clang::CompilerInstance&)’: ../src/gallium/frontends/clover/llvm/codegen/common.cpp:211:62: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 211 | const unsigned target_align = dl.getABITypeAlignment(arg_type); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ In file included from /usr/include/llvm/IR/Module.h:24, from ../src/gallium/frontends/clover/llvm/codegen.hpp:35, from ../src/gallium/frontends/clover/llvm/codegen/common.cpp:36: /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ ../src/gallium/frontends/clover/llvm/codegen/common.cpp:232:53: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 232 | dl.getABITypeAlignment(size_type), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ ../src/gallium/frontends/clover/llvm/codegen/common.cpp:240:53: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 240 | dl.getABITypeAlignment(size_type), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ ../src/gallium/frontends/clover/llvm/codegen/common.cpp:262:92: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 262 | (pointee_type->isVoidTy()) ? 8 : dl.getABITypeAlignment(pointee_type), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~ /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ ../src/gallium/frontends/clover/llvm/codegen/common.cpp:304:47: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 304 | dl.getABITypeAlignment(size_type), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ ../src/gallium/frontends/clover/llvm/codegen/common.cpp:310:47: warning: ‘uint64_t llvm::DataLayout::getABITypeAlignment(llvm::Type*) const’ is deprecated: use getABITypeAlign instead [-Wdeprecated-declarations] 310 | dl.getABITypeAlignment(size_type), | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ /usr/include/llvm/IR/DataLayout.h:527:12: note: declared here 527 | uint64_t getABITypeAlignment(Type *Ty) const; | ^~~~~~~~~~~~~~~~~~~ v2: * Use compat helper function (Karol Herbst) Part-of: --- src/gallium/frontends/clover/llvm/codegen/common.cpp | 15 +++++++++------ src/gallium/frontends/clover/llvm/compat.hpp | 10 ++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gallium/frontends/clover/llvm/codegen/common.cpp b/src/gallium/frontends/clover/llvm/codegen/common.cpp index 6bf15d8..fe5fc76 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 7bcf3d6..d2acaa8 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) { -- 2.7.4