[Mesa-dev] [PATCH v1] clover/llvm: Drop support for LLVM < 3.9.
Vedran Miletić
vedran at miletic.net
Sun Oct 8 23:08:07 UTC 2017
---
src/gallium/state_trackers/clover/llvm/compat.hpp | 59 +---------------------
.../state_trackers/clover/llvm/invocation.cpp | 2 -
.../state_trackers/clover/llvm/metadata.hpp | 30 +----------
3 files changed, 2 insertions(+), 89 deletions(-)
diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp b/src/gallium/state_trackers/clover/llvm/compat.hpp
index f8b56516d5..a626e4fd4e 100644
--- a/src/gallium/state_trackers/clover/llvm/compat.hpp
+++ b/src/gallium/state_trackers/clover/llvm/compat.hpp
@@ -46,15 +46,8 @@
#include <llvm/Support/ErrorOr.h>
#endif
-#if HAVE_LLVM >= 0x0307
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
-#else
-#include <llvm/PassManager.h>
-#include <llvm/Target/TargetLibraryInfo.h>
-#include <llvm/Target/TargetSubtargetInfo.h>
-#include <llvm/Support/FormattedStream.h>
-#endif
#include <clang/Basic/TargetInfo.h>
#include <clang/Frontend/CodeGenOptions.h>
@@ -63,11 +56,7 @@
namespace clover {
namespace llvm {
namespace compat {
-#if HAVE_LLVM >= 0x0307
typedef ::llvm::TargetLibraryInfoImpl target_library_info;
-#else
- typedef ::llvm::TargetLibraryInfo target_library_info;
-#endif
#if HAVE_LLVM >= 0x0500
const auto lang_as_offset = 0;
@@ -83,11 +72,7 @@ namespace clover {
const ::llvm::Triple &t,
clang::PreprocessorOptions &ppopts,
clang::LangStandard::Kind std) {
-#if HAVE_LLVM >= 0x0309
inv.setLangDefaults(lopts, ik, t, ppopts, std);
-#else
- inv.setLangDefaults(lopts, ik, std);
-#endif
}
inline void
@@ -100,79 +85,41 @@ namespace clover {
F.PropagateAttrs = true;
F.LinkFlags = ::llvm::Linker::Flags::None;
opts.LinkBitcodeFiles.emplace_back(F);
-#elif HAVE_LLVM >= 0x0308
- opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
#else
- opts.LinkBitcodeFile = path;
+ opts.LinkBitcodeFiles.emplace_back(::llvm::Linker::Flags::None, path);
#endif
}
-#if HAVE_LLVM >= 0x0307
typedef ::llvm::legacy::PassManager pass_manager;
-#else
- typedef ::llvm::PassManager pass_manager;
-#endif
-
- inline void
- add_data_layout_pass(pass_manager &pm) {
-#if HAVE_LLVM < 0x0307
- pm.add(new ::llvm::DataLayoutPass());
-#endif
- }
inline void
add_internalize_pass(pass_manager &pm,
const std::vector<std::string> &names) {
-#if HAVE_LLVM >= 0x0309
pm.add(::llvm::createInternalizePass(
[=](const ::llvm::GlobalValue &gv) {
return std::find(names.begin(), names.end(),
gv.getName()) != names.end();
}));
-#else
- pm.add(::llvm::createInternalizePass(std::vector<const char *>(
- map(std::mem_fn(&std::string::data), names))));
-#endif
}
inline std::unique_ptr< ::llvm::Linker>
create_linker(::llvm::Module &mod) {
-#if HAVE_LLVM >= 0x0308
return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker(mod));
-#else
- return std::unique_ptr< ::llvm::Linker>(new ::llvm::Linker(&mod));
-#endif
}
inline bool
link_in_module(::llvm::Linker &linker,
std::unique_ptr< ::llvm::Module> mod) {
-#if HAVE_LLVM >= 0x0308
return linker.linkInModule(std::move(mod));
-#else
- return linker.linkInModule(mod.get());
-#endif
}
-#if HAVE_LLVM >= 0x0307
typedef ::llvm::raw_svector_ostream &raw_ostream_to_emit_file;
-#else
- typedef ::llvm::formatted_raw_ostream raw_ostream_to_emit_file;
-#endif
-#if HAVE_LLVM >= 0x0307
typedef ::llvm::DataLayout data_layout;
-#else
- typedef const ::llvm::DataLayout *data_layout;
-#endif
inline data_layout
get_data_layout(::llvm::TargetMachine &tm) {
-#if HAVE_LLVM >= 0x0307
return tm.createDataLayout();
-#else
- return tm.getSubtargetImpl()->getDataLayout();
-#endif
}
#if HAVE_LLVM >= 0x0600
@@ -181,11 +128,7 @@ namespace clover {
const auto default_code_model = ::llvm::CodeModel::Default;
#endif
-#if HAVE_LLVM >= 0x0309
const auto default_reloc_model = ::llvm::None;
-#else
- const auto default_reloc_model = ::llvm::Reloc::Default;
-#endif
template<typename M, typename F> void
handle_module_error(M &mod, const F &f) {
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index a373df4eac..789d3f65e8 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -225,8 +225,6 @@ namespace {
bool internalize_symbols) {
compat::pass_manager pm;
- compat::add_data_layout_pass(pm);
-
// By default, the function internalizer pass will look for a function
// called "main" and then mark all other functions as internal. Marking
// functions as internal enables the optimizer to perform optimizations
diff --git a/src/gallium/state_trackers/clover/llvm/metadata.hpp b/src/gallium/state_trackers/clover/llvm/metadata.hpp
index 825008d497..bf8d9d5b06 100644
--- a/src/gallium/state_trackers/clover/llvm/metadata.hpp
+++ b/src/gallium/state_trackers/clover/llvm/metadata.hpp
@@ -57,44 +57,16 @@ namespace clover {
inline bool
is_kernel(const ::llvm::Function &f) {
-#if HAVE_LLVM >= 0x0309
return f.getMetadata("kernel_arg_type");
-#else
- return clover::any_of(is_kernel_node_for(f),
- get_kernel_nodes(*f.getParent()));
-#endif
}
inline iterator_range< ::llvm::MDNode::op_iterator>
get_kernel_metadata_operands(const ::llvm::Function &f,
const std::string &name) {
-#if HAVE_LLVM >= 0x0309
- // On LLVM v3.9+ kernel argument attributes are stored as
+ // LLVM stores kernel argument attributes as
// function metadata.
const auto data_node = f.getMetadata(name);
return range(data_node->op_begin(), data_node->op_end());
-#else
- using ::llvm::cast;
- using ::llvm::dyn_cast;
- const auto kernel_node = find(is_kernel_node_for(f),
- get_kernel_nodes(*f.getParent()));
-
- const auto data_node = cast< ::llvm::MDNode>(
- find([&](const ::llvm::MDOperand &op) {
- if (auto m = dyn_cast< ::llvm::MDNode>(op))
- if (m->getNumOperands())
- if (auto m_name = dyn_cast< ::llvm::MDString>(
- m->getOperand(0).get()))
- return m_name->getString() == name;
-
- return false;
- },
- kernel_node->operands()));
-
- // Skip the first operand node which is just the metadata
- // attribute name.
- return range(data_node->op_begin() + 1, data_node->op_end());
-#endif
}
}
--
2.14.2
More information about the mesa-dev
mailing list