Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPU LLVM Precompilation Fixup #14569

Merged
merged 1 commit into from Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 17 additions & 22 deletions rpcs3/Emu/Cell/SPURecompiler.cpp
Expand Up @@ -699,7 +699,19 @@ void spu_cache::initialize()
auto data_list = std::move(g_fxo->get<spu_section_data>().data);
g_fxo->get<spu_section_data>().had_been_used = true;

atomic_t<usz> data_indexer{};
const bool spu_precompilation_enabled = func_list.empty() && g_cfg.core.spu_cache && g_cfg.core.llvm_precompilation;

if (spu_precompilation_enabled)
{
// What compiles in this case goes straight to disk
g_fxo->get<spu_cache>() = std::move(cache);
}
else
{
data_list.clear();
}

atomic_t<usz> data_indexer = 0;

if (g_cfg.core.spu_decoder == spu_decoder_type::dynamic || g_cfg.core.spu_decoder == spu_decoder_type::llvm)
{
Expand Down Expand Up @@ -742,12 +754,9 @@ void spu_cache::initialize()

u32 add_count = ::size32(func_list);

if (func_list.empty())
for (auto& sec : data_list)
{
for (auto& sec : data_list)
{
add_count += sec.funcs.size();
}
add_count += sec.funcs.size();
}

g_progr_ptotal += add_count;
Expand Down Expand Up @@ -847,12 +856,6 @@ void spu_cache::initialize()
result++;
}

if (!func_list.empty() || !g_cfg.core.llvm_precompilation)
{
// Cache has already been initiated or the user does not want to precompile SPU programs
return result;
}

u32 last_sec_idx = umax;

for (usz func_i = data_indexer++;; func_i = data_indexer++, g_progr_pdone++)
Expand Down Expand Up @@ -1077,7 +1080,7 @@ void spu_cache::initialize()
}

// Initialize global cache instance
if (g_cfg.core.spu_cache)
if (g_cfg.core.spu_cache && cache)
{
g_fxo->get<spu_cache>() = std::move(cache);
}
Expand Down Expand Up @@ -2900,8 +2903,6 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)
}
}

spu_program result2 = result;

while (lsa > 0 || limit < 0x40000)
{
const u32 initial_size = ::size32(result.data);
Expand Down Expand Up @@ -3348,13 +3349,7 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)
{
workload.clear();
workload.push_back(entry_point);
if (!m_bbs.count(entry_point))
{
std::string func_bad;
dump(result2, func_bad);
spu_log.error("%s", func_bad);
return {};
}
ensure(m_bbs.count(entry_point));

std::basic_string<u32> new_entries;

Expand Down
14 changes: 0 additions & 14 deletions rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -487,20 +487,6 @@ std::array<u32, 2> op_branch_targets(u32 pc, spu_opcode_t op)
case spu_itype::BRASL:
{
const int index = (type == spu_itype::BR || type == spu_itype::BRA || type == spu_itype::BRSL || type == spu_itype::BRASL ? 0 : 1);

// if (type == spu_itype::BRASL || type == spu_itype::BRA)
// {
// res[index] = spu_branch_target(0, op.i16);
// }
// else
// {
// // Treat i16 as signed, this allows the caller to detect "overflows" and "underflows" in address in order to detect invalid branches
// // Example:
// // [0x3fffc] BR +4 -> BR 0 -> invalid
// // [0x3fffc] BR 0x3fff4 -> BR 0 -> invalid
// const u32 add = static_cast<s16>(op.si16);
// }

res[index] = (spu_branch_target(type == spu_itype::BRASL || type == spu_itype::BRA ? 0 : pc, op.i16));

if (res[0] == res[1])
Expand Down