Add a read barrier after every label.

This commit is contained in:
Skyth 2024-09-26 16:52:18 +03:00
parent 261e8c1d60
commit 7fa7ff161f
2 changed files with 5 additions and 1 deletions

View File

@ -1968,7 +1968,11 @@ bool Recompiler::Recompile(const Function& fn)
while (base < end)
{
if (labels.contains(base))
{
println("loc_{:X}:", base);
// With a read barrier we prevent the compiler from doing unsafe code reordering. I wonder if we could do this better...
println("\t_ReadBarrier();");
}
if (switchTable == switchTables.end())
switchTable = switchTables.find(base);

View File

@ -9,12 +9,12 @@
#include <cstring>
#include <cmath>
#include <csetjmp>
#include <intrin.h>
#ifdef __clang__
#include <x86intrin.h>
#define PPC_NOINLINE __attribute__((noinline))
#else
#include <intrin.h>
#define __restrict__ __restrict
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong