Improve JIT profiling on Linux

Add JIT object dumping functionality.
Add source for objdump interception utility.
This commit is contained in:
Nekotekina 2022-01-23 15:22:00 +03:00
parent 14951d8713
commit 11ee1f3eb2
4 changed files with 230 additions and 18 deletions

View file

@ -3487,7 +3487,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
#endif
// Get function chunk name
const std::string name = fmt::format("spu-cx%05x-%s", addr, fmt::base57(be_t<u64>{m_hash_start}));
const std::string name = fmt::format("__spu-cx%05x-%s", addr, fmt::base57(be_t<u64>{m_hash_start}));
llvm::Function* result = llvm::cast<llvm::Function>(m_module->getOrInsertFunction(name, chunk_type).getCallee());
// Set parameters
@ -3512,7 +3512,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
// 5. $3
const auto func_type = get_ftype<u32[4], u8*, u8*, u32, u32[4], u32[4]>();
const std::string fname = fmt::format("spu-fx%05x-%s", addr, fmt::base57(be_t<u64>{m_hash_start}));
const std::string fname = fmt::format("__spu-fx%05x-%s", addr, fmt::base57(be_t<u64>{m_hash_start}));
llvm::Function* fn = llvm::cast<llvm::Function>(m_module->getOrInsertFunction(fname, func_type).getCallee());
fn->setLinkage(llvm::GlobalValue::InternalLinkage);
@ -4381,7 +4381,7 @@ public:
sha1_finish(&ctx, output);
m_hash.clear();
fmt::append(m_hash, "spu-0x%05x-%s", func.entry_point, fmt::base57(output));
fmt::append(m_hash, "__spu-0x%05x-%s", func.entry_point, fmt::base57(output));
be_t<u64> hash_start;
std::memcpy(&hash_start, output, sizeof(hash_start));
@ -4649,7 +4649,7 @@ public:
m_ir->CreateUnreachable();
}
m_dispatch = cast<Function>(_module->getOrInsertFunction("spu-null", entry_chunk->chunk->getFunctionType()).getCallee());
m_dispatch = cast<Function>(_module->getOrInsertFunction("__spu-null", entry_chunk->chunk->getFunctionType()).getCallee());
m_dispatch->setLinkage(llvm::GlobalValue::InternalLinkage);
m_dispatch->setCallingConv(entry_chunk->chunk->getCallingConv());
set_function(m_dispatch);