Support LLVM 9+ build changes
Bug: b/139412871
Change-Id: Ia9e49317fa9ce89dcacaa1e5a788518062e4e633
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40730
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index a696532..68a29ee 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -52,7 +52,7 @@
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Intrinsics.h"
-#if LLVM_VERSION_MAJOR >= 8
+#if LLVM_VERSION_MAJOR >= 9
# include "llvm/IR/IntrinsicsX86.h"
#endif
#include "llvm/IR/LLVMContext.h"
@@ -178,7 +178,7 @@
static JITGlobals *get();
const std::string mcpu;
- const std::vector<std::string> mattrs;
+ const std::vector<llvm::StringRef> mattrs;
const char *const march;
const llvm::TargetOptions targetOptions;
const llvm::DataLayout dataLayout;
@@ -189,7 +189,7 @@
static JITGlobals create();
static llvm::CodeGenOpt::Level toLLVM(rr::Optimization::Level level);
JITGlobals(const char *mcpu,
- const std::vector<std::string> &mattrs,
+ const std::vector<llvm::StringRef> &mattrs,
const char *march,
const llvm::TargetOptions &targetOptions,
const llvm::DataLayout &dataLayout);
@@ -248,7 +248,8 @@
(void)ok; // getHostCPUFeatures always returns false on other platforms
#endif
- std::vector<std::string> mattrs;
+ std::vector<llvm::StringRef> mattrs;
+
for(auto &feature : features)
{
if(feature.second) { mattrs.push_back(feature.first()); }
@@ -306,7 +307,7 @@
}
JITGlobals::JITGlobals(const char *mcpu,
- const std::vector<std::string> &mattrs,
+ const std::vector<llvm::StringRef> &mattrs,
const char *march,
const llvm::TargetOptions &targetOptions,
const llvm::DataLayout &dataLayout)
@@ -350,7 +351,7 @@
// Round down base address to align with a page boundary. This matches
// DefaultMMapper behavior.
void *addr = block.base();
-#if LLVM_VERSION_MAJOR >= 8
+#if LLVM_VERSION_MAJOR >= 9
size_t size = block.allocatedSize();
#else
size_t size = block.size();
@@ -367,7 +368,7 @@
std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block)
{
-#if LLVM_VERSION_MAJOR >= 8
+#if LLVM_VERSION_MAJOR >= 9
size_t size = block.allocatedSize();
#else
size_t size = block.size();
@@ -418,8 +419,8 @@
const rr::Config &config)
: resolver(createLegacyLookupResolver(
session,
- [&](const std::string &name) {
- void *func = rr::resolveExternalSymbol(name.c_str());
+ [&](const llvm::StringRef &name) {
+ void *func = rr::resolveExternalSymbol(name.str().c_str());
if(func != nullptr)
{
return llvm::JITSymbol(
@@ -5078,7 +5079,7 @@
// Run manadory coroutine transforms.
llvm::legacy::PassManager pm;
-#if LLVM_VERSION_MAJOR >= 8
+#if LLVM_VERSION_MAJOR >= 9
pm.add(llvm::createCoroEarlyLegacyPass());
pm.add(llvm::createCoroSplitLegacyPass());
pm.add(llvm::createCoroElideLegacyPass());