From 5b0476e77212c96a10f096cc37b2018a2db52a0c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 24 Feb 2020 20:39:39 +0300 Subject: [PATCH] Update LLVM to new llvm-mirror (LLVM 11) Use clang-cl to build LLVM on Windows. --- .gitmodules | 2 +- .travis/build-linux.bash | 2 +- 3rdparty/llvm.cmake | 10 +++++----- Utilities/JIT.cpp | 6 +++--- appveyor.yml | 2 +- llvm | 2 +- rpcs3/Emu/CPU/CPUTranslator.h | 1 + rpcs3/Emu/Cell/PPUTranslator.cpp | 6 +++--- rpcs3/Emu/Cell/SPURecompiler.cpp | 2 +- rpcs3_llvm.props | 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.gitmodules b/.gitmodules index dd8d8e3a72..c773416e3b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,7 +8,7 @@ ignore = dirty [submodule "llvm"] path = llvm - url = https://github.com/RPCS3/llvm + url = https://github.com/RPCS3/llvm-mirror ignore = dirty [submodule "Vulkan/glslang"] path = Vulkan/glslang diff --git a/.travis/build-linux.bash b/.travis/build-linux.bash index da6aa5c0d4..35271b0629 100644 --- a/.travis/build-linux.bash +++ b/.travis/build-linux.bash @@ -11,7 +11,7 @@ cd rpcs3 git submodule update --quiet --init asmjit 3rdparty/ffmpeg 3rdparty/pugixml 3rdparty/span 3rdparty/libpng 3rdparty/cereal 3rdparty/hidapi 3rdparty/xxHash 3rdparty/yaml-cpp 3rdparty/libusb 3rdparty/FAudio Vulkan/glslang # Download pre-compiled llvm libs -curl -sLO https://github.com/RPCS3/llvm/releases/download/continuous-linux-master/llvmlibs-linux.tar.gz +curl -sLO https://github.com/RPCS3/llvm-mirror/releases/download/custom-build/llvmlibs-linux.tar.gz mkdir llvmlibs tar -xzf ./llvmlibs-linux.tar.gz -C llvmlibs diff --git a/3rdparty/llvm.cmake b/3rdparty/llvm.cmake index d71d463bea..3886f0fbcd 100644 --- a/3rdparty/llvm.cmake +++ b/3rdparty/llvm.cmake @@ -12,7 +12,7 @@ if(WITH_LLVM) option(LLVM_INCLUDE_TOOLS OFF) option(LLVM_INCLUDE_UTILS OFF) option(WITH_POLLY OFF) - option(LLVM_ENABLE_CXX1Z TRUE) + option(LLVM_CCACHE_BUILD ON) set(CXX_FLAGS_OLD ${CMAKE_CXX_FLAGS}) @@ -27,7 +27,7 @@ if(WITH_LLVM) set(CMAKE_CXX_FLAGS ${CXX_FLAGS_OLD}) # now tries to find LLVM again - find_package(LLVM 10.0 CONFIG) + find_package(LLVM 11.0 CONFIG) if(NOT LLVM_FOUND) message(FATAL_ERROR "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`") endif() @@ -40,11 +40,11 @@ if(WITH_LLVM) set(LLVM_DIR ${CMAKE_SOURCE_DIR}/${LLVM_DIR}) endif() - find_package(LLVM 10.0 CONFIG) + find_package(LLVM 11.0 CONFIG) if (NOT LLVM_FOUND) - if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 9) - message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required version 9.0. \ + if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 11) + message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required version 11.0. \ Enable BUILD_LLVM_SUBMODULE option to build LLVM from included as a git submodule.") endif() diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 53bdb056c4..6b3b91d611 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -918,7 +918,7 @@ public: void notifyObjectCompiled(const llvm::Module* module, llvm::MemoryBufferRef obj) override { std::string name = m_path; - name.append(module->getName()); + name.append(module->getName().data()); //fs::file(name, fs::rewrite).write(obj.getBufferStart(), obj.getBufferSize()); name.append(".gz"); @@ -1026,7 +1026,7 @@ public: std::unique_ptr getObject(const llvm::Module* module) override { std::string path = m_path; - path.append(module->getName()); + path.append(module->getName().data()); if (auto buf = load(path)) { @@ -1044,7 +1044,7 @@ std::string jit_compiler::cpu(const std::string& _cpu) if (m_cpu.empty()) { - m_cpu = llvm::sys::getHostCPUName(); + m_cpu = llvm::sys::getHostCPUName().operator std::string(); if (m_cpu == "sandybridge" || m_cpu == "ivybridge" || diff --git a/appveyor.yml b/appveyor.yml index a842a62799..e1214627d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,7 +5,7 @@ image: Visual Studio 2019 environment: QTDIR: C:\Qt\5.14\msvc2017_64 - LLVMLIBS: https://github.com/RPCS3/llvm/releases/download/continuous-master/llvmlibs.7z + LLVMLIBS: https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win/llvmlibs.7z GLSLANG: https://www.dropbox.com/s/6e8w6t5dxh3ad4l/glslang.7z?dl=1 COMPATDB: https://rpcs3.net/compatibility?api=v1&export VULKAN_SDK: "C:\\VulkanSDK\\1.1.126.0" diff --git a/llvm b/llvm index 1394b1ccc8..0c0b09edb7 160000 --- a/llvm +++ b/llvm @@ -1 +1 @@ -Subproject commit 1394b1ccc8cfee2846b1a38d409717e821113cf3 +Subproject commit 0c0b09edb75fcca1cb3c909b58db2caaf95dd631 diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index a6d7c99fe6..a83e505b37 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -16,6 +16,7 @@ #include "llvm/IR/Module.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/IR/IntrinsicsX86.h" #ifdef _MSC_VER #pragma warning(pop) #else diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index aef2c43edf..3e4df3c63b 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -537,12 +537,12 @@ Value* PPUTranslator::ReadMemory(Value* addr, Type* type, bool is_be, u32 align) { // Read, byteswap, bitcast const auto int_type = m_ir->getIntNTy(size); - const auto value = m_ir->CreateAlignedLoad(GetMemory(addr, int_type), align, true); + const auto value = m_ir->CreateAlignedLoad(GetMemory(addr, int_type), llvm::MaybeAlign{align}, true); return m_ir->CreateBitCast(Call(int_type, fmt::format("llvm.bswap.i%u", size), value), type); } // Read normally - return m_ir->CreateAlignedLoad(GetMemory(addr, type), align, true); + return m_ir->CreateAlignedLoad(GetMemory(addr, type), llvm::MaybeAlign{align}, true); } void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align) @@ -558,7 +558,7 @@ void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align } // Write - m_ir->CreateAlignedStore(value, GetMemory(addr, value->getType()), align, true); + m_ir->CreateAlignedStore(value, GetMemory(addr, value->getType()), llvm::MaybeAlign{align}, true); } void PPUTranslator::CompilationError(const std::string& error) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 897e04b1ed..cacfe08309 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -4346,7 +4346,7 @@ public: } // Load unaligned code block from LS - llvm::Value* vls = m_ir->CreateAlignedLoad(_ptr(data_addr, j - starta), 4); + llvm::Value* vls = m_ir->CreateAlignedLoad(_ptr(data_addr, j - starta), llvm::MaybeAlign{4}); // Mask if necessary if (holes) diff --git a/rpcs3_llvm.props b/rpcs3_llvm.props index 6284ffd1ec..eca1791861 100644 --- a/rpcs3_llvm.props +++ b/rpcs3_llvm.props @@ -10,7 +10,7 @@ ..\llvm_build\Debug\lib ..\llvm_build\Release\lib - LLVMProfileData.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoMSF.lib;LLVMInstrumentation.lib;LLVMMCJIT.lib;LLVMRuntimeDyld.lib;LLVMVectorize.lib;LLVMX86CodeGen.lib;LLVMGlobalISel.lib;LLVMX86Disassembler.lib;LLVMExecutionEngine.lib;LLVMAsmPrinter.lib;LLVMSelectionDAG.lib;LLVMCodeGen.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMTarget.lib;LLVMX86Desc.lib;LLVMObject.lib;LLVMMCParser.lib;LLVMBitReader.lib;LLVMCore.lib;LLVMX86Utils.lib;LLVMMC.lib;LLVMX86Info.lib;LLVMSupport.lib;LLVMMCDisassembler.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMPasses.lib;LLVMIRReader.lib;LLVMLinker.lib;LLVMAsmParser.lib;LLVMX86AsmParser.lib;LLVMDemangle.lib;LLVMDebugInfoDWARF.lib;LLVMRemarks.lib;LLVMBitstreamReader.lib;LLVMTextAPI.lib + LLVMProfileData.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoMSF.lib;LLVMInstrumentation.lib;LLVMMCJIT.lib;LLVMRuntimeDyld.lib;LLVMVectorize.lib;LLVMX86CodeGen.lib;LLVMGlobalISel.lib;LLVMX86Disassembler.lib;LLVMExecutionEngine.lib;LLVMAsmPrinter.lib;LLVMSelectionDAG.lib;LLVMCodeGen.lib;LLVMScalarOpts.lib;LLVMInstCombine.lib;LLVMTransformUtils.lib;LLVMAnalysis.lib;LLVMTarget.lib;LLVMX86Desc.lib;LLVMObject.lib;LLVMMCParser.lib;LLVMBitReader.lib;LLVMCore.lib;LLVMX86Utils.lib;LLVMMC.lib;LLVMX86Info.lib;LLVMSupport.lib;LLVMMCDisassembler.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMPasses.lib;LLVMIRReader.lib;LLVMLinker.lib;LLVMAsmParser.lib;LLVMX86AsmParser.lib;LLVMDemangle.lib;LLVMDebugInfoDWARF.lib;LLVMRemarks.lib;LLVMBitstreamReader.lib;LLVMTextAPI.lib;LLVMCFGuard.lib