From fcc841eaa1360b8fae961f1c690f9c2ff7bfbd46 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 14 Nov 2019 19:09:34 +0300 Subject: [PATCH] LLVM: Add workaround for znver2 --- Utilities/JIT.cpp | 10 ++++++++-- Utilities/sysinfo.cpp | 6 ++++++ Utilities/sysinfo.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 84a99f2ad2..10d2e635d5 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -490,7 +490,7 @@ private: }; Segment m_curr; - std::vector m_segs; + std::vector m_segs; }; // Memory manager mutex @@ -581,7 +581,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager if (m_tramps) { const s64 tramps_diff = u64(m_tramps) - code_start; - if (tramps_diff < INT_MIN || tramps_diff > INT_MAX) + if (tramps_diff < INT_MIN || tramps_diff > INT_MAX) m_tramps = nullptr; //previously allocated trampoline section too far away now } @@ -965,6 +965,12 @@ std::string jit_compiler::cpu(const std::string& _cpu) m_cpu = "skylake"; } } + + if (m_cpu == "znver1" && utils::has_clwb()) + { + // Upgrade + m_cpu = "znver2"; + } } return m_cpu; diff --git a/Utilities/sysinfo.cpp b/Utilities/sysinfo.cpp index 2f45f56575..94a138eb9f 100755 --- a/Utilities/sysinfo.cpp +++ b/Utilities/sysinfo.cpp @@ -69,6 +69,12 @@ bool utils::has_xop() return g_value; } +bool utils::has_clwb() +{ + static const bool g_value = get_cpuid(0, 0)[0] >= 0x7 && (get_cpuid(7, 0)[1] & 0x1000000) == 0x1000000; + return g_value; +} + std::string utils::get_system_info() { std::string result; diff --git a/Utilities/sysinfo.h b/Utilities/sysinfo.h index 7479529544..3eab517be5 100755 --- a/Utilities/sysinfo.h +++ b/Utilities/sysinfo.h @@ -45,6 +45,8 @@ namespace utils bool has_xop(); + bool has_clwb(); + std::string get_system_info(); std::string get_firmware_version();