From 78673b614b01a8a416367db23937743c0e1aaa36 Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Thu, 15 Feb 2018 14:00:38 -0500 Subject: [PATCH] clover: Fix build after llvm r325155 and r325160 r325155 ("Pass a reference to a module to the bitcode writer.") and r325160 ("Pass module reference to CloneModule") change function interface from pointer to reference. v2: Fix indentation (tab instead of spaces) Signed-off-by: Jan Vesely Reviewed-by: Francisco Jerez --- .../state_trackers/clover/llvm/codegen/bitcode.cpp | 2 +- .../state_trackers/clover/llvm/codegen/native.cpp | 2 +- src/gallium/state_trackers/clover/llvm/compat.hpp | 28 ++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp index 679ecd8..40bb426 100644 --- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp +++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp @@ -66,7 +66,7 @@ namespace { emit_code(const ::llvm::Module &mod) { ::llvm::SmallVector data; ::llvm::raw_svector_ostream os { data }; - WriteBitcodeToFile(&mod, os); + compat::write_bitcode_to_file(mod, os); return { os.str().begin(), os.str().end() }; } } diff --git a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp index 12c83a9..409f8ac 100644 --- a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp +++ b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp @@ -156,7 +156,7 @@ clover::llvm::print_module_native(const ::llvm::Module &mod, const target &target) { std::string log; try { - std::unique_ptr< ::llvm::Module> cmod { CloneModule(&mod) }; + std::unique_ptr< ::llvm::Module> cmod { compat::clone_module(mod) }; return as_string(emit_code(*cmod, target, TargetMachine::CGFT_AssemblyFile, log)); } catch (...) { diff --git a/src/gallium/state_trackers/clover/llvm/compat.hpp b/src/gallium/state_trackers/clover/llvm/compat.hpp index 6fc75fb..19528a0 100644 --- a/src/gallium/state_trackers/clover/llvm/compat.hpp +++ b/src/gallium/state_trackers/clover/llvm/compat.hpp @@ -36,9 +36,17 @@ #include "util/algorithm.hpp" +#if HAVE_LLVM < 0x0400 +#include +#else +#include +#include +#endif + #include #include #include +#include #include #if HAVE_LLVM >= 0x0400 #include @@ -217,6 +225,26 @@ namespace clover { ctx.setDiagnosticHandler(diagnostic_handler, data); #endif } + + inline std::unique_ptr< ::llvm::Module> + clone_module(const ::llvm::Module &mod) + { +#if HAVE_LLVM >= 0x0700 + return ::llvm::CloneModule(mod); +#else + return ::llvm::CloneModule(&mod); +#endif + } + + template void + write_bitcode_to_file(const ::llvm::Module &mod, T &os) + { +#if HAVE_LLVM >= 0x0700 + ::llvm::WriteBitcodeToFile(mod, os); +#else + ::llvm::WriteBitcodeToFile(&mod, os); +#endif + } } } } -- 2.7.4