summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Martin <edb@sigluy.net>2020-08-23 07:57:12 +0200
committerSerge Martin <edb@sigluy.net>2020-09-26 11:06:42 +0200
commita3543adc2628461818cfa691a7f547af7bc6f0fb (patch)
treea854721c70dfe9d2c6a03a643ff76d196844adab
parentbf80fb7c3098d4e03b11971238bec51954cd0a30 (diff)
clover: set LLVM min version to 8.0.1
It also bump from 8.0.0 to .1 for AMD gallium and VK Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6336>
-rw-r--r--.gitlab-ci.yml19
-rw-r--r--meson.build4
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/bitcode.cpp8
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/common.cpp14
-rw-r--r--src/gallium/frontends/clover/llvm/codegen/native.cpp6
-rw-r--r--src/gallium/frontends/clover/llvm/compat.hpp123
-rw-r--r--src/gallium/frontends/clover/llvm/invocation.cpp16
7 files changed, 29 insertions, 161 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2af0ee88ab1..0f2b55a8e40 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -787,25 +787,6 @@ meson-clover:
- .gitlab-ci/meson-build.sh
- LLVM_VERSION=8 .gitlab-ci/meson-build.sh
-meson-clover-old-llvm:
- extends:
- - meson-clover
- - .use-x86_build_old
- variables:
- UNWIND: "disabled"
- DRI_LOADERS: >
- -D glx=disabled
- -D egl=disabled
- -D gbm=disabled
- -D platforms=[]
- GALLIUM_DRIVERS: "i915,r600"
- script:
- - LLVM_VERSION=3.9 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=4.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=5.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=6.0 .gitlab-ci/meson-build.sh
- - LLVM_VERSION=7 .gitlab-ci/meson-build.sh
-
meson-vulkan:
extends: .meson-build
variables:
diff --git a/meson.build b/meson.build
index 50e105efa55..76f72a9df7c 100644
--- a/meson.build
+++ b/meson.build
@@ -1450,8 +1450,7 @@ if with_gallium_opencl
]
endif
-with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
-if with_amd_vk or with_gallium_radeonsi or with_opencl_spirv
+if with_amd_vk or with_gallium_radeonsi or with_gallium_opencl
_llvm_version = '>= 8.0.0'
elif with_gallium_swr
_llvm_version = '>= 6.0.0'
@@ -1545,6 +1544,7 @@ elif with_gallium_opencl
error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
endif
+with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
if with_opencl_spirv
chosen_llvm_version_array = dep_llvm.version().split('.')
chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
diff --git a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
index 7434e8cf6c9..413f11031d3 100644
--- a/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/bitcode.cpp
@@ -55,7 +55,7 @@ namespace {
emit_code(const ::llvm::Module &mod) {
::llvm::SmallVector<char, 1024> data;
::llvm::raw_svector_ostream os { data };
- compat::write_bitcode_to_file(mod, os);
+ ::llvm::WriteBitcodeToFile(mod, os);
return { os.str().begin(), os.str().end() };
}
}
@@ -83,9 +83,11 @@ clover::llvm::parse_module_library(const module &m, ::llvm::LLVMContext &ctx,
auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
as_string(m.secs[0].data), " "), ctx);
- compat::handle_module_error(mod, [&](const std::string &s) {
- fail(r_log, error(CL_INVALID_PROGRAM), s);
+ if (::llvm::Error err = mod.takeError()) {
+ ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
+ fail(r_log, error(CL_INVALID_PROGRAM), eib.message());
});
+ }
return std::unique_ptr< ::llvm::Module>(std::move(*mod));
}
diff --git a/src/gallium/frontends/clover/llvm/codegen/common.cpp b/src/gallium/frontends/clover/llvm/codegen/common.cpp
index 730ba5a2ff7..3404087a000 100644
--- a/src/gallium/frontends/clover/llvm/codegen/common.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/common.cpp
@@ -82,12 +82,10 @@ namespace {
// type that is not a power of two bytes in size must be
// aligned to the next larger power of two.
// This rule applies to built-in types only, not structs or unions."
- const unsigned arg_store_size = dl.getTypeStoreSize(arg_type);
const unsigned arg_api_size = dl.getTypeAllocSize(arg_type);
- const auto target_type = compat::get_abi_type(arg_type, mod);
- const unsigned target_size = dl.getTypeStoreSize(target_type);
- const unsigned target_align = dl.getABITypeAlignment(target_type);
+ const unsigned target_size = dl.getTypeStoreSize(arg_type);
+ const unsigned target_align = dl.getABITypeAlignment(arg_type);
const auto type_name = get_argument_metadata(f, arg,
"kernel_arg_type");
@@ -97,7 +95,7 @@ namespace {
const auto access_qual = get_argument_metadata(
f, arg, "kernel_arg_access_qual");
args.emplace_back(get_image_type(type_name, access_qual),
- arg_store_size, target_size,
+ target_size, target_size,
target_align, module::argument::zero_ext);
} else if (type_name == "__llvm_image_size") {
@@ -126,8 +124,10 @@ namespace {
const unsigned address_space =
cast< ::llvm::PointerType>(actual_type)->getAddressSpace();
- if (address_space == compat::target_address_space(
- c.getTarget(), clang::LangAS::opencl_local)) {
+ const auto &map = c.getTarget().getAddressSpaceMap();
+ const auto offset =
+ static_cast<unsigned>(clang::LangAS::opencl_local);
+ if (address_space == map[offset]) {
args.emplace_back(module::argument::local, arg_api_size,
target_size, target_align,
module::argument::zero_ext);
diff --git a/src/gallium/frontends/clover/llvm/codegen/native.cpp b/src/gallium/frontends/clover/llvm/codegen/native.cpp
index 52346131200..bc07fc3b032 100644
--- a/src/gallium/frontends/clover/llvm/codegen/native.cpp
+++ b/src/gallium/frontends/clover/llvm/codegen/native.cpp
@@ -114,7 +114,7 @@ namespace {
std::unique_ptr<TargetMachine> tm {
t->createTargetMachine(target.triple, target.cpu, "", {},
- ::llvm::None, compat::default_code_model,
+ ::llvm::None, ::llvm::None,
::llvm::CodeGenOpt::Default) };
if (!tm)
fail(r_log, build_error(),
@@ -130,7 +130,7 @@ namespace {
tm->Options.MCOptions.AsmVerbose =
(ft == compat::CGFT_AssemblyFile);
- if (compat::add_passes_to_emit_file(*tm, pm, os, ft))
+ if (tm->addPassesToEmitFile(pm, os, nullptr, ft))
fail(r_log, build_error(), "TargetMachine can't emit this file");
pm.run(mod);
@@ -154,7 +154,7 @@ clover::llvm::print_module_native(const ::llvm::Module &mod,
const target &target) {
std::string log;
try {
- std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) };
+ std::unique_ptr< ::llvm::Module> cmod { ::llvm::CloneModule(mod) };
return as_string(emit_code(*cmod, target,
compat::CGFT_AssemblyFile, log));
} catch (...) {
diff --git a/src/gallium/frontends/clover/llvm/compat.hpp b/src/gallium/frontends/clover/llvm/compat.hpp
index 51902739acc..78eb8c982a8 100644
--- a/src/gallium/frontends/clover/llvm/compat.hpp
+++ b/src/gallium/frontends/clover/llvm/compat.hpp
@@ -37,23 +37,12 @@
#include "util/algorithm.hpp"
#include <llvm/Config/llvm-config.h>
-#if LLVM_VERSION_MAJOR < 4
-#include <llvm/Bitcode/ReaderWriter.h>
-#else
-#include <llvm/Bitcode/BitcodeReader.h>
-#include <llvm/Bitcode/BitcodeWriter.h>
-#endif
#include <llvm/IR/LLVMContext.h>
#include <llvm/Linker/Linker.h>
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/Cloning.h>
#include <llvm/Target/TargetMachine.h>
-#if LLVM_VERSION_MAJOR >= 4
-#include <llvm/Support/Error.h>
-#else
-#include <llvm/Support/ErrorOr.h>
-#endif
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
@@ -61,12 +50,6 @@
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CompilerInstance.h>
-#if LLVM_VERSION_MAJOR >= 8
-#include <clang/Basic/CodeGenOptions.h>
-#else
-#include <clang/Frontend/CodeGenOptions.h>
-#endif
-
#if LLVM_VERSION_MAJOR >= 10
#include <llvm/Support/CodeGen.h>
#endif
@@ -86,103 +69,11 @@ namespace clover {
typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType;
#endif
- template<typename T, typename AS>
- unsigned target_address_space(const T &target, const AS lang_as) {
- const auto &map = target.getAddressSpaceMap();
-#if LLVM_VERSION_MAJOR >= 5
- return map[static_cast<unsigned>(lang_as)];
-#else
- return map[lang_as - clang::LangAS::Offset];
-#endif
- }
-
#if LLVM_VERSION_MAJOR >= 10
const clang::InputKind ik_opencl = clang::Language::OpenCL;
-#elif LLVM_VERSION_MAJOR >= 5
- const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
-#else
- const clang::InputKind ik_opencl = clang::IK_OpenCL;
-#endif
-
-#if LLVM_VERSION_MAJOR >= 5
- const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl10;
-#else
- const clang::LangStandard::Kind lang_opencl10 = clang::LangStandard::lang_opencl;
-#endif
-
- inline void
- add_link_bitcode_file(clang::CodeGenOptions &opts,
- const std::string &path) {
-#if LLVM_VERSION_MAJOR >= 5
- clang::CodeGenOptions::BitcodeFileToLink F;
-
- F.Filename = path;
- F.PropagateAttrs = true;
- F.LinkFlags = ::llvm::Linker::Flags::None;
- opts.LinkBitcodeFiles.emplace_back(F);
-#else
- opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
-#endif
- }
-
-#if LLVM_VERSION_MAJOR >= 6
- const auto default_code_model = ::llvm::None;
-#else
- const auto default_code_model = ::llvm::CodeModel::Default;
-#endif
-
- template<typename M, typename F> void
- handle_module_error(M &mod, const F &f) {
-#if LLVM_VERSION_MAJOR >= 4
- if (::llvm::Error err = mod.takeError())
- ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
- f(eib.message());
- });
#else
- if (!mod)
- f(mod.getError().message());
-#endif
- }
-
- template<typename T> void
- set_diagnostic_handler(::llvm::LLVMContext &ctx,
- T *diagnostic_handler, void *data) {
-#if LLVM_VERSION_MAJOR >= 6
- ctx.setDiagnosticHandlerCallBack(diagnostic_handler, data);
-#else
- ctx.setDiagnosticHandler(diagnostic_handler, data);
-#endif
- }
-
- inline std::unique_ptr< ::llvm::Module>
- clone_module(const ::llvm::Module &mod)
- {
-#if LLVM_VERSION_MAJOR >= 7
- return ::llvm::CloneModule(mod);
-#else
- return ::llvm::CloneModule(&mod);
-#endif
- }
-
- template<typename T> void
- write_bitcode_to_file(const ::llvm::Module &mod, T &os)
- {
-#if LLVM_VERSION_MAJOR >= 7
- ::llvm::WriteBitcodeToFile(mod, os);
-#else
- ::llvm::WriteBitcodeToFile(&mod, os);
-#endif
- }
-
- template<typename TM, typename PM, typename OS, typename FT>
- bool add_passes_to_emit_file(TM &tm, PM &pm, OS &os, FT &ft)
- {
-#if LLVM_VERSION_MAJOR >= 7
- return tm.addPassesToEmitFile(pm, os, nullptr, ft);
-#else
- return tm.addPassesToEmitFile(pm, os, ft);
+ const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
#endif
- }
template<typename T> inline bool
create_compiler_invocation_from_args(clang::CompilerInvocation &cinv,
@@ -197,18 +88,6 @@ namespace clover {
cinv, copts.data(), copts.data() + copts.size(), diag);
#endif
}
-
- template<typename T, typename M>
- T get_abi_type(const T &arg_type, const M &mod) {
-#if LLVM_VERSION_MAJOR >= 7
- return arg_type;
-#else
- ::llvm::DataLayout dl(&mod);
- const unsigned arg_store_size = dl.getTypeStoreSize(arg_type);
- return !arg_type->isIntegerTy() ? arg_type :
- dl.getSmallestLegalIntType(mod.getContext(), arg_store_size * 8);
-#endif
- }
}
}
}
diff --git a/src/gallium/frontends/clover/llvm/invocation.cpp b/src/gallium/frontends/clover/llvm/invocation.cpp
index 173894fa799..2516de016a8 100644
--- a/src/gallium/frontends/clover/llvm/invocation.cpp
+++ b/src/gallium/frontends/clover/llvm/invocation.cpp
@@ -91,7 +91,7 @@ namespace {
};
const clc_version_lang_std cl_version_lang_stds[] = {
- { 100, compat::lang_opencl10},
+ { 100, clang::LangStandard::lang_opencl10},
{ 110, clang::LangStandard::lang_opencl11},
{ 120, clang::LangStandard::lang_opencl12},
{ 200, clang::LangStandard::lang_opencl20},
@@ -124,7 +124,8 @@ namespace {
create_context(std::string &r_log) {
init_targets();
std::unique_ptr<LLVMContext> ctx { new LLVMContext };
- compat::set_diagnostic_handler(*ctx, diagnostic_handler, &r_log);
+
+ ctx->setDiagnosticHandlerCallBack(diagnostic_handler, &r_log);
return ctx;
}
@@ -296,9 +297,14 @@ namespace {
// attribute will prevent Clang from creating illegal uses of
// barrier() (e.g. Moving barrier() inside a conditional that is
// no executed by all threads) during its optimizaton passes.
- if (use_libclc)
- compat::add_link_bitcode_file(c.getCodeGenOpts(),
- LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc");
+ if (use_libclc) {
+ clang::CodeGenOptions::BitcodeFileToLink F;
+
+ F.Filename = LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc";
+ F.PropagateAttrs = true;
+ F.LinkFlags = ::llvm::Linker::Flags::None;
+ c.getCodeGenOpts().LinkBitcodeFiles.emplace_back(F);
+ }
// undefine __IMAGE_SUPPORT__ for device without image support
if (!dev.image_support())