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>
This commit is contained in:
@@ -787,25 +787,6 @@ meson-clover:
|
|||||||
- .gitlab-ci/meson-build.sh
|
- .gitlab-ci/meson-build.sh
|
||||||
- LLVM_VERSION=8 .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:
|
meson-vulkan:
|
||||||
extends: .meson-build
|
extends: .meson-build
|
||||||
variables:
|
variables:
|
||||||
|
@@ -1450,8 +1450,7 @@ if with_gallium_opencl
|
|||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
|
if with_amd_vk or with_gallium_radeonsi or with_gallium_opencl
|
||||||
if with_amd_vk or with_gallium_radeonsi or with_opencl_spirv
|
|
||||||
_llvm_version = '>= 8.0.0'
|
_llvm_version = '>= 8.0.0'
|
||||||
elif with_gallium_swr
|
elif with_gallium_swr
|
||||||
_llvm_version = '>= 6.0.0'
|
_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.')
|
error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
with_opencl_spirv = _opencl != 'disabled' and get_option('opencl-spirv')
|
||||||
if with_opencl_spirv
|
if with_opencl_spirv
|
||||||
chosen_llvm_version_array = dep_llvm.version().split('.')
|
chosen_llvm_version_array = dep_llvm.version().split('.')
|
||||||
chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
|
chosen_llvm_version_major = chosen_llvm_version_array[0].to_int()
|
||||||
|
@@ -55,7 +55,7 @@ namespace {
|
|||||||
emit_code(const ::llvm::Module &mod) {
|
emit_code(const ::llvm::Module &mod) {
|
||||||
::llvm::SmallVector<char, 1024> data;
|
::llvm::SmallVector<char, 1024> data;
|
||||||
::llvm::raw_svector_ostream os { 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() };
|
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(
|
auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
|
||||||
as_string(m.secs[0].data), " "), ctx);
|
as_string(m.secs[0].data), " "), ctx);
|
||||||
|
|
||||||
compat::handle_module_error(mod, [&](const std::string &s) {
|
if (::llvm::Error err = mod.takeError()) {
|
||||||
fail(r_log, error(CL_INVALID_PROGRAM), s);
|
::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));
|
return std::unique_ptr< ::llvm::Module>(std::move(*mod));
|
||||||
}
|
}
|
||||||
|
@@ -82,12 +82,10 @@ namespace {
|
|||||||
// type that is not a power of two bytes in size must be
|
// type that is not a power of two bytes in size must be
|
||||||
// aligned to the next larger power of two.
|
// aligned to the next larger power of two.
|
||||||
// This rule applies to built-in types only, not structs or unions."
|
// 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 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(arg_type);
|
||||||
const unsigned target_size = dl.getTypeStoreSize(target_type);
|
const unsigned target_align = dl.getABITypeAlignment(arg_type);
|
||||||
const unsigned target_align = dl.getABITypeAlignment(target_type);
|
|
||||||
|
|
||||||
const auto type_name = get_argument_metadata(f, arg,
|
const auto type_name = get_argument_metadata(f, arg,
|
||||||
"kernel_arg_type");
|
"kernel_arg_type");
|
||||||
@@ -97,7 +95,7 @@ namespace {
|
|||||||
const auto access_qual = get_argument_metadata(
|
const auto access_qual = get_argument_metadata(
|
||||||
f, arg, "kernel_arg_access_qual");
|
f, arg, "kernel_arg_access_qual");
|
||||||
args.emplace_back(get_image_type(type_name, 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);
|
target_align, module::argument::zero_ext);
|
||||||
|
|
||||||
} else if (type_name == "__llvm_image_size") {
|
} else if (type_name == "__llvm_image_size") {
|
||||||
@@ -126,8 +124,10 @@ namespace {
|
|||||||
const unsigned address_space =
|
const unsigned address_space =
|
||||||
cast< ::llvm::PointerType>(actual_type)->getAddressSpace();
|
cast< ::llvm::PointerType>(actual_type)->getAddressSpace();
|
||||||
|
|
||||||
if (address_space == compat::target_address_space(
|
const auto &map = c.getTarget().getAddressSpaceMap();
|
||||||
c.getTarget(), clang::LangAS::opencl_local)) {
|
const auto offset =
|
||||||
|
static_cast<unsigned>(clang::LangAS::opencl_local);
|
||||||
|
if (address_space == map[offset]) {
|
||||||
args.emplace_back(module::argument::local, arg_api_size,
|
args.emplace_back(module::argument::local, arg_api_size,
|
||||||
target_size, target_align,
|
target_size, target_align,
|
||||||
module::argument::zero_ext);
|
module::argument::zero_ext);
|
||||||
|
@@ -114,7 +114,7 @@ namespace {
|
|||||||
|
|
||||||
std::unique_ptr<TargetMachine> tm {
|
std::unique_ptr<TargetMachine> tm {
|
||||||
t->createTargetMachine(target.triple, target.cpu, "", {},
|
t->createTargetMachine(target.triple, target.cpu, "", {},
|
||||||
::llvm::None, compat::default_code_model,
|
::llvm::None, ::llvm::None,
|
||||||
::llvm::CodeGenOpt::Default) };
|
::llvm::CodeGenOpt::Default) };
|
||||||
if (!tm)
|
if (!tm)
|
||||||
fail(r_log, build_error(),
|
fail(r_log, build_error(),
|
||||||
@@ -130,7 +130,7 @@ namespace {
|
|||||||
tm->Options.MCOptions.AsmVerbose =
|
tm->Options.MCOptions.AsmVerbose =
|
||||||
(ft == compat::CGFT_AssemblyFile);
|
(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");
|
fail(r_log, build_error(), "TargetMachine can't emit this file");
|
||||||
|
|
||||||
pm.run(mod);
|
pm.run(mod);
|
||||||
@@ -154,7 +154,7 @@ clover::llvm::print_module_native(const ::llvm::Module &mod,
|
|||||||
const target &target) {
|
const target &target) {
|
||||||
std::string log;
|
std::string log;
|
||||||
try {
|
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,
|
return as_string(emit_code(*cmod, target,
|
||||||
compat::CGFT_AssemblyFile, log));
|
compat::CGFT_AssemblyFile, log));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
@@ -37,23 +37,12 @@
|
|||||||
#include "util/algorithm.hpp"
|
#include "util/algorithm.hpp"
|
||||||
|
|
||||||
#include <llvm/Config/llvm-config.h>
|
#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/IR/LLVMContext.h>
|
||||||
#include <llvm/Linker/Linker.h>
|
#include <llvm/Linker/Linker.h>
|
||||||
#include <llvm/Transforms/IPO.h>
|
#include <llvm/Transforms/IPO.h>
|
||||||
#include <llvm/Transforms/Utils/Cloning.h>
|
#include <llvm/Transforms/Utils/Cloning.h>
|
||||||
#include <llvm/Target/TargetMachine.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/IR/LegacyPassManager.h>
|
||||||
#include <llvm/Analysis/TargetLibraryInfo.h>
|
#include <llvm/Analysis/TargetLibraryInfo.h>
|
||||||
@@ -61,12 +50,6 @@
|
|||||||
#include <clang/Basic/TargetInfo.h>
|
#include <clang/Basic/TargetInfo.h>
|
||||||
#include <clang/Frontend/CompilerInstance.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
|
#if LLVM_VERSION_MAJOR >= 10
|
||||||
#include <llvm/Support/CodeGen.h>
|
#include <llvm/Support/CodeGen.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -86,104 +69,12 @@ namespace clover {
|
|||||||
typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType;
|
typedef ::llvm::TargetMachine::CodeGenFileType CodeGenFileType;
|
||||||
#endif
|
#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
|
#if LLVM_VERSION_MAJOR >= 10
|
||||||
const clang::InputKind ik_opencl = clang::Language::OpenCL;
|
const clang::InputKind ik_opencl = clang::Language::OpenCL;
|
||||||
#elif LLVM_VERSION_MAJOR >= 5
|
#else
|
||||||
const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
|
const clang::InputKind ik_opencl = clang::InputKind::OpenCL;
|
||||||
#else
|
|
||||||
const clang::InputKind ik_opencl = clang::IK_OpenCL;
|
|
||||||
#endif
|
#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);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> inline bool
|
template<typename T> inline bool
|
||||||
create_compiler_invocation_from_args(clang::CompilerInvocation &cinv,
|
create_compiler_invocation_from_args(clang::CompilerInvocation &cinv,
|
||||||
T copts,
|
T copts,
|
||||||
@@ -195,18 +86,6 @@ namespace clover {
|
|||||||
#else
|
#else
|
||||||
return clang::CompilerInvocation::CreateFromArgs(
|
return clang::CompilerInvocation::CreateFromArgs(
|
||||||
cinv, copts.data(), copts.data() + copts.size(), diag);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -91,7 +91,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const clc_version_lang_std cl_version_lang_stds[] = {
|
const clc_version_lang_std cl_version_lang_stds[] = {
|
||||||
{ 100, compat::lang_opencl10},
|
{ 100, clang::LangStandard::lang_opencl10},
|
||||||
{ 110, clang::LangStandard::lang_opencl11},
|
{ 110, clang::LangStandard::lang_opencl11},
|
||||||
{ 120, clang::LangStandard::lang_opencl12},
|
{ 120, clang::LangStandard::lang_opencl12},
|
||||||
{ 200, clang::LangStandard::lang_opencl20},
|
{ 200, clang::LangStandard::lang_opencl20},
|
||||||
@@ -124,7 +124,8 @@ namespace {
|
|||||||
create_context(std::string &r_log) {
|
create_context(std::string &r_log) {
|
||||||
init_targets();
|
init_targets();
|
||||||
std::unique_ptr<LLVMContext> ctx { new LLVMContext };
|
std::unique_ptr<LLVMContext> ctx { new LLVMContext };
|
||||||
compat::set_diagnostic_handler(*ctx, diagnostic_handler, &r_log);
|
|
||||||
|
ctx->setDiagnosticHandlerCallBack(diagnostic_handler, &r_log);
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,9 +297,14 @@ namespace {
|
|||||||
// attribute will prevent Clang from creating illegal uses of
|
// attribute will prevent Clang from creating illegal uses of
|
||||||
// barrier() (e.g. Moving barrier() inside a conditional that is
|
// barrier() (e.g. Moving barrier() inside a conditional that is
|
||||||
// no executed by all threads) during its optimizaton passes.
|
// no executed by all threads) during its optimizaton passes.
|
||||||
if (use_libclc)
|
if (use_libclc) {
|
||||||
compat::add_link_bitcode_file(c.getCodeGenOpts(),
|
clang::CodeGenOptions::BitcodeFileToLink F;
|
||||||
LIBCLC_LIBEXECDIR + dev.ir_target() + ".bc");
|
|
||||||
|
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
|
// undefine __IMAGE_SUPPORT__ for device without image support
|
||||||
if (!dev.image_support())
|
if (!dev.image_support())
|
||||||
|
Reference in New Issue
Block a user