@@ -4643,8 +4643,15 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
4643
4643
// Copy block or function entry
4644
4644
ppu_function& entry = part.funcs .emplace_back (func);
4645
4645
4646
+ u32 og_func = entry.addr ;
4647
+
4648
+ if (auto it = info.duplicate_map .find (entry.addr ); it != info.duplicate_map .end ())
4649
+ {
4650
+ og_func = it->second ;
4651
+ }
4652
+
4646
4653
// Fixup some information
4647
- entry.name = fmt::format (" __0x%x" , entry. addr - reloc);
4654
+ entry.name = fmt::format (" __0x%x" , og_func - reloc);
4648
4655
4649
4656
if (has_mfvscr && g_cfg.core .ppu_set_sat_bit )
4650
4657
{
@@ -5037,6 +5044,8 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
5037
5044
5038
5045
bool early_exit = false ;
5039
5046
5047
+ std::map<std::string, ppu_intrp_func_t > func_ptr_map;
5048
+
5040
5049
// Get and install function addresses
5041
5050
for (const auto & func : info.funcs )
5042
5051
{
@@ -5063,10 +5072,14 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
5063
5072
5064
5073
const auto name = fmt::format (" __0x%x" , og_func - reloc);
5065
5074
5075
+ ppu_intrp_func_t dummy{};
5076
+ ppu_intrp_func_t & func_ptr = is_first ? func_ptr_map[name] : dummy;
5077
+
5066
5078
// Try to locate existing function if it is not the first time
5067
- const auto addr = is_first ? ensure (reinterpret_cast <ppu_intrp_func_t >(jit->get (name)))
5079
+ const auto addr = is_first ? (func_ptr ? func_ptr : ensure (reinterpret_cast <ppu_intrp_func_t >(jit->get (name) )))
5068
5080
: reinterpret_cast <ppu_intrp_func_t >(ensure (jit_mod.funcs [index ]));
5069
5081
5082
+ func_ptr = addr;
5070
5083
jit_mod.funcs .emplace_back (addr);
5071
5084
5072
5085
if (func.size == 4 && !BLR_func && *info.get_ptr <u32>(func.addr ) == ppu_instructions::BLR ())
@@ -5155,6 +5168,11 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
5155
5168
{
5156
5169
if (func.size )
5157
5170
{
5171
+ if (auto it = module_part.duplicate_map .find (func.addr ); it != module_part.duplicate_map .end () && it->second != it->first )
5172
+ {
5173
+ continue ;
5174
+ }
5175
+
5158
5176
const auto f = cast<Function>(_module->getOrInsertFunction (func.name , _func).getCallee ());
5159
5177
f->setCallingConv (CallingConv::GHC);
5160
5178
f->addParamAttr (1 , llvm::Attribute::NoAlias);
0 commit comments