SPU LLVM: use updateGlobalMapping instead of addGlobalMapping

...Where appropriate.
Fix to incorrect addGlobalMapping usage.
Also use clearAllGlobalMappings at compilation start.
This commit is contained in:
Nekotekina 2019-11-17 22:09:23 +03:00
parent f30b81f8b0
commit db4e201fee
2 changed files with 8 additions and 4 deletions

View File

@ -2458,7 +2458,7 @@ public:
#ifdef _WIN32
func->setCallingConv(llvm::CallingConv::Win64);
#endif
m_engine->addGlobalMapping({lame.data(), lame.size()}, reinterpret_cast<std::uintptr_t>(_func));
m_engine->updateGlobalMapping({lame.data(), lame.size()}, reinterpret_cast<std::uintptr_t>(_func));
const auto inst = m_ir->CreateCall(func, {args...});
#ifdef _WIN32

View File

@ -3407,7 +3407,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
// Register under a unique linkable name
const std::string ppname = fmt::format("%s-pp-%u", m_hash, m_pp_id++);
m_engine->addGlobalMapping(ppname, (u64)m_spurt->make_branch_patchpoint());
m_engine->updateGlobalMapping(ppname, reinterpret_cast<u64>(m_spurt->make_branch_patchpoint()));
// Create function with not exactly correct type
const auto ppfunc = llvm::cast<llvm::Function>(m_module->getOrInsertFunction(ppname, m_finfo->chunk->getFunctionType()).getCallee());
@ -4232,6 +4232,8 @@ public:
using namespace llvm;
m_engine->clearAllGlobalMappings();
// Create LLVM module
std::unique_ptr<Module> module = std::make_unique<Module>(m_hash + ".obj", m_context);
module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));
@ -4386,7 +4388,7 @@ public:
entry_call->setCallingConv(entry_chunk->chunk->getCallingConv());
const auto dispatcher = llvm::cast<llvm::Function>(m_module->getOrInsertFunction("spu_dispatcher", main_func->getType()).getCallee());
m_engine->addGlobalMapping("spu_dispatcher", reinterpret_cast<u64>(spu_runtime::tr_all));
m_engine->updateGlobalMapping("spu_dispatcher", reinterpret_cast<u64>(spu_runtime::tr_all));
dispatcher->setCallingConv(main_func->getCallingConv());
// Proceed to the next code
@ -4663,7 +4665,7 @@ public:
if (false && g_cfg.core.spu_verification)
{
const std::string ppname = fmt::format("%s-chunkpp-0x%05x", m_hash, i);
m_engine->addGlobalMapping(ppname, (u64)m_spurt->make_branch_patchpoint(i / 4));
m_engine->updateGlobalMapping(ppname, reinterpret_cast<u64>(m_spurt->make_branch_patchpoint(i / 4)));
const auto ppfunc = llvm::cast<llvm::Function>(m_module->getOrInsertFunction(ppname, m_finfo->chunk->getFunctionType()).getCallee());
ppfunc->setCallingConv(m_finfo->chunk->getCallingConv());
@ -4836,6 +4838,8 @@ public:
{
using namespace llvm;
m_engine->clearAllGlobalMappings();
// Create LLVM module
std::unique_ptr<Module> module = std::make_unique<Module>("spu_interpreter.obj", m_context);
module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));