SPU LLVM: improve debugging RPCS3

Build cache in reverse order
Catch exceptions in instruction loop: print IR
This commit is contained in:
Nekotekina 2018-08-03 15:34:51 +03:00
parent 711e0f75ee
commit 14e6577700
2 changed files with 23 additions and 10 deletions

View file

@ -33,9 +33,9 @@ spu_cache::~spu_cache()
{ {
} }
std::vector<std::vector<u32>> spu_cache::get() std::deque<std::vector<u32>> spu_cache::get()
{ {
std::vector<std::vector<u32>> result; std::deque<std::vector<u32>> result;
if (!m_file) if (!m_file)
{ {
@ -64,7 +64,7 @@ std::vector<std::vector<u32>> spu_cache::get()
break; break;
} }
result.emplace_back(std::move(func)); result.emplace_front(std::move(func));
} }
return result; return result;
@ -2161,6 +2161,11 @@ public:
fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log); fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log);
} }
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
}
using namespace llvm; using namespace llvm;
// Create LLVM module // Create LLVM module
@ -2447,7 +2452,19 @@ public:
} }
// Execute recompiler function (TODO) // Execute recompiler function (TODO)
(this->*g_decoder.decode(op))({op}); try
{
(this->*g_decoder.decode(op))({op});
}
catch (const std::exception& e)
{
std::string dump;
raw_string_ostream out(dump);
out << *module; // print IR
out.flush();
LOG_ERROR(SPU, "[0x%x] LLVM dump:\n%s", m_pos, dump);
throw;
}
} }
// Finalize block with fallthrough if necessary // Finalize block with fallthrough if necessary
@ -2780,11 +2797,6 @@ public:
fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log); fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log);
} }
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
}
return fn; return fn;
} }

View file

@ -6,6 +6,7 @@
#include <bitset> #include <bitset>
#include <memory> #include <memory>
#include <string> #include <string>
#include <deque>
// Helper class // Helper class
class spu_cache class spu_cache
@ -22,7 +23,7 @@ public:
return m_file.operator bool(); return m_file.operator bool();
} }
std::vector<std::vector<u32>> get(); std::deque<std::vector<u32>> get();
void add(const std::vector<u32>& func); void add(const std::vector<u32>& func);