SPU LLVM: Expand SPU Profiling to blocks

This commit is contained in:
Elad 2026-02-26 15:50:37 +02:00
parent 1ec3de9e8f
commit 45c6e938a5
4 changed files with 13 additions and 7 deletions

View file

@ -206,11 +206,7 @@ struct cpu_prof
// Print only 7 hash characters out of 11 (which covers roughly 48 bits)
if (type_id == 2)
{
fmt::append(results, "\n\t[%s", fmt::base57(be_t<u64>{name}));
results.resize(results.size() - 4);
// Print chunk address from lowest 16 bits
fmt::append(results, "...chunk-0x%05x]: %.4f%% (%u)", (name & 0xffff) * 4, _frac * 100., count);
fmt::append(results, "\n\t[%s]: %.4f%% (%u)", spu_block_hash{name}, _frac * 100., count);
}
else
{

View file

@ -7391,6 +7391,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out)
SPUDisAsm dis_asm(cpu_disasm_mode::dump, reinterpret_cast<const u8*>(result.data.data()), result.lower_bound);
std::string hash;
be_t<u64> hash_start{};
if (!result.data.empty())
{
@ -7401,6 +7402,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out)
sha1_update(&ctx, reinterpret_cast<const u8*>(result.data.data()), result.data.size() * 4);
sha1_finish(&ctx, output);
fmt::append(hash, "%s", fmt::base57(output));
std::memcpy(&hash_start, output, sizeof(hash_start));
}
else
{
@ -7413,7 +7415,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out)
{
if (m_block_info[bb.first / 4])
{
fmt::append(out, "A: [0x%05x] %s\n", bb.first, m_entry_info[bb.first / 4] ? (m_ret_info[bb.first / 4] ? "Chunk" : "Entry") : "Block");
fmt::append(out, "A: [0x%05x] %s [%s]\n", bb.first, m_entry_info[bb.first / 4] ? (m_ret_info[bb.first / 4] ? "Chunk" : "Entry") : "Block", spu_block_hash{(hash_start & -65536) + bb.first / 4});
fmt::append(out, "\t F: 0x%05x\n", bb.second.func);

View file

@ -2160,6 +2160,14 @@ public:
}
}
if (bb.preds.size() >= 2)
{
if (g_cfg.core.spu_prof || g_cfg.core.spu_debug)
{
m_ir->CreateStore(m_ir->getInt64((m_hash_start & -65536) | (baddr >> 2)), spu_ptr(&spu_thread::block_hash));
}
}
// State check at the beginning of the chunk
if (need_check || (bi == 0 && g_cfg.core.spu_block_size != spu_block_size_type::safe))
{

View file

@ -164,7 +164,7 @@ void fmt_class_string<spu_block_hash>::format(std::string& out, u64 arg)
out.resize(out.size() - 4);
// Print chunk address from lowest 16 bits
fmt::append(out, "...chunk-0x%05x", (arg & 0xffff) * 4);
fmt::append(out, "-0x%05x", (arg & 0xffff) * 4);
}
enum class spu_block_hash_short : u64{};