Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to LLVM 16.0.1 #13629

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/build-freebsd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git submodule -q update --init --depth 1 $(awk '/path/ && !/llvm/ && !/SPIRV/ {

# Prefer newer Clang than in base system (see also .ci/install-freebsd.sh)
# libc++ isn't in llvm* packages, so download manually
fetch https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/llvm-project-16.0.0.src.tar.xz
fetch https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.1/llvm-project-16.0.1.src.tar.xz
tar xf llvm*.tar.xz
export CC=clang16 CXX=clang++16
cmake -B libcxx_build -G Ninja -S llvm*/libcxx \
Expand Down
2 changes: 1 addition & 1 deletion .ci/get_keys-windows.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh -ex

curl -L -o "./llvm.lock" "https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.0/llvmlibs_mt.7z.sha256"
curl -L -o "./llvm.lock" "https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.1/llvmlibs_mt.7z.sha256"
curl -L -o "./glslang.lock" "https://github.com/RPCS3/glslang/releases/download/custom-build-win/glslanglibs_mt.7z.sha256"
2 changes: 1 addition & 1 deletion .ci/setup-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ QT_DECL_URL="${QT_HOST}${QT_PREFIX}qtdeclarative${QT_SUFFIX}"
QT_TOOL_URL="${QT_HOST}${QT_PREFIX}qttools${QT_SUFFIX}"
QT_MM_URL="${QT_HOST}${QT_PREFIX}qtmultimedia${QT_SUFFIX}"
QT_SVG_URL="${QT_HOST}${QT_PREFIX}qtsvg${QT_SUFFIX}"
LLVMLIBS_URL='https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.0/llvmlibs_mt.7z'
LLVMLIBS_URL='https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.1/llvmlibs_mt.7z'
GLSLANG_URL='https://github.com/RPCS3/glslang/releases/download/custom-build-win/glslanglibs_mt.7z'
VULKAN_SDK_URL="https://www.dropbox.com/s/cs77c3iv5mbo0bt/VulkanSDK-${VULKAN_VER}-Installer.exe"

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/llvm/llvm
Submodule llvm updated 204 files
2 changes: 1 addition & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ git submodule update --init

Open `rpcs3.sln`. The recommended build configuration is `Release`. (On older revisions: `Release - LLVM`)

You may want to download the precompiled [LLVM libs](https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.0/llvmlibs_mt.7z) and extract them to `3rdparty\llvm\`, as well as download and extract the [additional libs](https://github.com/RPCS3/glslang/releases/download/custom-build-win/glslanglibs_mt.7z) to `lib\%CONFIGURATION%-x64\` to speed up compilation time (unoptimised/debug libs are currently not available precompiled).
You may want to download the precompiled [LLVM libs](https://github.com/RPCS3/llvm-mirror/releases/download/custom-build-win-16.0.1/llvmlibs_mt.7z) and extract them to `3rdparty\llvm\`, as well as download and extract the [additional libs](https://github.com/RPCS3/glslang/releases/download/custom-build-win/glslanglibs_mt.7z) to `lib\%CONFIGURATION%-x64\` to speed up compilation time (unoptimised/debug libs are currently not available precompiled).

If you're not using the precompiled libs, build the following projects in *__BUILD_BEFORE* folder by right-clicking on a project > *Build*.:
* glslang
Expand Down
36 changes: 31 additions & 5 deletions Utilities/JIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,14 +1373,42 @@ std::string jit_compiler::cpu(const std::string& _cpu)
return m_cpu;
}

std::string jit_compiler::triple1()
{
#if defined(_WIN32)
return llvm::Triple::normalize(llvm::sys::getProcessTriple());
#elif defined(__APPLE__) && defined(ARCH_X64)
return llvm::Triple::normalize("x86_64-unknown-linux-gnu");
#elif defined(__APPLE__) && defined(ARCH_ARM64)
return llvm::Triple::normalize("aarch64-unknown-linux-gnu");
#else
return llvm::Triple::normalize(llvm::sys::getProcessTriple());
#endif
}

std::string jit_compiler::triple2()
{
#if defined(_WIN32) && defined(ARCH_X64)
return llvm::Triple::normalize("x86_64-unknown-linux-gnu");
#elif defined(_WIN32) && defined(ARCH_ARM64)
return llvm::Triple::normalize("aarch64-unknown-linux-gnu");
#elif defined(__APPLE__) && defined(ARCH_X64)
return llvm::Triple::normalize("x86_64-unknown-linux-gnu");
#elif defined(__APPLE__) && defined(ARCH_ARM64)
return llvm::Triple::normalize("aarch64-unknown-linux-gnu");
#else
return llvm::Triple::normalize(llvm::sys::getProcessTriple());
#endif
}

jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, const std::string& _cpu, u32 flags)
: m_context(new llvm::LLVMContext)
, m_cpu(cpu(_cpu))
{
std::string result;

auto null_mod = std::make_unique<llvm::Module> ("null_", *m_context);
null_mod->setTargetTriple(llvm::Triple::normalize(llvm::sys::getProcessTriple()));
null_mod->setTargetTriple(jit_compiler::triple1());

std::unique_ptr<llvm::RTDyldMemoryManager> mem;

Expand All @@ -1394,9 +1422,7 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
else
{
mem = std::make_unique<MemoryManager2>();
#if defined(_WIN32) && defined(ARCH_X64)
null_mod->setTargetTriple(llvm::Triple::normalize("x86_64-unknown-linux-gnu"));
#endif
null_mod->setTargetTriple(jit_compiler::triple2());
}
}
else
Expand All @@ -1412,7 +1438,7 @@ jit_compiler::jit_compiler(const std::unordered_map<std::string, u64>& _link, co
.setOptLevel(llvm::CodeGenOpt::Aggressive)
.setCodeModel(flags & 0x2 ? llvm::CodeModel::Large : llvm::CodeModel::Small)
#ifdef __APPLE__
.setCodeModel(llvm::CodeModel::Large)
//.setCodeModel(llvm::CodeModel::Large)
#endif
.setRelocationModel(llvm::Reloc::Model::PIC_)
.setMCPU(m_cpu)
Expand Down
6 changes: 6 additions & 0 deletions Utilities/JIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ class jit_compiler final

// Get CPU info
static std::string cpu(const std::string& _cpu);

// Get system triple (PPU)
static std::string triple1();

// Get system triple (SPU)
static std::string triple2();
};

#endif
7 changes: 5 additions & 2 deletions rpcs3/Emu/CPU/CPUTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin
cpu == "bdver2" ||
cpu == "bdver3" ||
cpu == "bdver4" ||
cpu.startswith("znver"))
cpu == "znver1" ||
cpu == "znver2" ||
cpu == "znver3")
{
m_use_fma = true;
m_use_avx = true;
Expand Down Expand Up @@ -158,7 +160,8 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin
cpu == "icelake-server" ||
cpu == "tigerlake" ||
cpu == "rocketlake" ||
cpu == "sapphirerapids")
cpu == "sapphirerapids" ||
(cpu.startswith("znver") && cpu != "znver1" && cpu != "znver2" && cpu != "znver3"))
{
m_use_avx = true;
m_use_fma = true;
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/CPU/CPUTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#endif
#include "llvm/IR/LLVMContext.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ static void ppu_check(ppu_thread& ppu, u64 addr)

// ppu_check() shall not return directly
if (ppu.test_stopped())
;
{}
ppu_escape(&ppu);
}

Expand Down Expand Up @@ -3690,7 +3690,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
// Settings: should be populated by settings which affect codegen (TODO)
enum class ppu_settings : u32
{
non_win32,
platform_bit,
accurate_dfma,
fixup_vnan,
fixup_nj_denormals,
Expand All @@ -3707,8 +3707,8 @@ bool ppu_initialize(const ppu_module& info, bool check_only)

be_t<bs_t<ppu_settings>> settings{};

#ifndef _WIN32
settings += ppu_settings::non_win32;
#if !defined(_WIN32) && !defined(__APPLE__)
settings += ppu_settings::platform_bit;
#endif
if (g_cfg.core.use_accurate_dfma)
settings += ppu_settings::accurate_dfma;
Expand Down Expand Up @@ -3937,7 +3937,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
std::unique_ptr<Module> _module = std::make_unique<Module>(obj_name, jit.get_context());

// Initialize target
_module->setTargetTriple(Triple::normalize(sys::getProcessTriple()));
_module->setTargetTriple(jit_compiler::triple1());
_module->setDataLayout(jit.get_engine().getTargetMachine()->createDataLayout());

// Initialize translator
Expand Down
Loading