Commit 6c3dc358 by Nicolas Capens Committed by Nicolas Capens

Support LLVM 8+ build changes

Bug: b/139412871 Change-Id: I7c6b59a19b6f2fdc6feb7420605c9e7935790a90 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40588 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 153a537a
...@@ -52,6 +52,9 @@ __pragma(warning(push)) ...@@ -52,6 +52,9 @@ __pragma(warning(push))
#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h" #include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Intrinsics.h"
#if LLVM_VERSION_MAJOR >= 8
# include "llvm/IR/IntrinsicsX86.h"
#endif
#include "llvm/IR/LLVMContext.h" #include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
...@@ -347,7 +350,11 @@ public: ...@@ -347,7 +350,11 @@ public:
// Round down base address to align with a page boundary. This matches // Round down base address to align with a page boundary. This matches
// DefaultMMapper behavior. // DefaultMMapper behavior.
void *addr = block.base(); void *addr = block.base();
#if LLVM_VERSION_MAJOR >= 8
size_t size = block.allocatedSize();
#else
size_t size = block.size(); size_t size = block.size();
#endif
size_t pageSize = rr::memoryPageSize(); size_t pageSize = rr::memoryPageSize();
addr = reinterpret_cast<void *>( addr = reinterpret_cast<void *>(
reinterpret_cast<uintptr_t>(addr) & ~(pageSize - 1)); reinterpret_cast<uintptr_t>(addr) & ~(pageSize - 1));
...@@ -360,7 +367,13 @@ public: ...@@ -360,7 +367,13 @@ public:
std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block) std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block)
{ {
rr::deallocateMemoryPages(block.base(), block.size()); #if LLVM_VERSION_MAJOR >= 8
size_t size = block.allocatedSize();
#else
size_t size = block.size();
#endif
rr::deallocateMemoryPages(block.base(), size);
return std::error_code(); return std::error_code();
} }
...@@ -5064,11 +5077,21 @@ std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Confi ...@@ -5064,11 +5077,21 @@ std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Confi
{ {
// Run manadory coroutine transforms. // Run manadory coroutine transforms.
llvm::legacy::PassManager pm; llvm::legacy::PassManager pm;
#if LLVM_VERSION_MAJOR >= 8
pm.add(llvm::createCoroEarlyLegacyPass());
pm.add(llvm::createCoroSplitLegacyPass());
pm.add(llvm::createCoroElideLegacyPass());
pm.add(llvm::createBarrierNoopPass());
pm.add(llvm::createCoroCleanupLegacyPass());
#else
pm.add(llvm::createCoroEarlyPass()); pm.add(llvm::createCoroEarlyPass());
pm.add(llvm::createCoroSplitPass()); pm.add(llvm::createCoroSplitPass());
pm.add(llvm::createCoroElidePass()); pm.add(llvm::createCoroElidePass());
pm.add(llvm::createBarrierNoopPass()); pm.add(llvm::createBarrierNoopPass());
pm.add(llvm::createCoroCleanupPass()); pm.add(llvm::createCoroCleanupPass());
#endif
pm.run(*jit->module); pm.run(*jit->module);
} }
...@@ -5100,4 +5123,4 @@ std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Confi ...@@ -5100,4 +5123,4 @@ std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Confi
return routine; return routine;
} }
} // namespace rr } // namespace rr
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment