java-topology/defects/rpcs3/patch/rpcs3-0001-spu-recompiler-preds-vector-dedup.patch

21 lines
963 B
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UNDF: UNDF-2026-000000904
--- a/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
+++ b/rpcs3/Emu/Cell/SPUCommonRecompiler.cpp
@@ -2899,4 +2899,5 @@
// Add predecessor
- if (std::find(m_preds[target].begin(), m_preds[target].end(), pos) == m_preds[target].end())
+ auto& pred_set = m_pred_sets[target];
+ if (pred_set.insert(pos).second)
{
m_preds[target].push_back(pos);
}
#
# CWE-407: SPU recompiler add_block scans m_preds[target] vector with
# std::find for every predecessor insertion — O(P) per edge where P =
# predecessors of target block. Called for every branch/target in SPU
# program analysis. For programs with many converging blocks, this is
# O(E×P) where E = total edges.
# Fix: maintain a parallel std::unordered_set<u32> per target for O(1)
# dedup, keeping the vector for ordered iteration.
# Severity: MEDIUM — recompilation is amortized but repeated per SPU
# program; large SPU kernels can have hundreds of blocks.