@@ -4643,8 +4643,15 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
46434643 // Copy block or function entry
46444644 ppu_function& entry = part.funcs .emplace_back (func);
46454645
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+
46464653 // Fixup some information
4647- entry.name = fmt::format (" __0x%x" , entry. addr - reloc);
4654+ entry.name = fmt::format (" __0x%x" , og_func - reloc);
46484655
46494656 if (has_mfvscr && g_cfg.core .ppu_set_sat_bit )
46504657 {
@@ -5037,6 +5044,8 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
50375044
50385045 bool early_exit = false ;
50395046
5047+ std::map<std::string, ppu_intrp_func_t > func_ptr_map;
5048+
50405049 // Get and install function addresses
50415050 for (const auto & func : info.funcs )
50425051 {
@@ -5063,10 +5072,14 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
50635072
50645073 const auto name = fmt::format (" __0x%x" , og_func - reloc);
50655074
5075+ ppu_intrp_func_t dummy{};
5076+ ppu_intrp_func_t & func_ptr = is_first ? func_ptr_map[name] : dummy;
5077+
50665078 // 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) )))
50685080 : reinterpret_cast <ppu_intrp_func_t >(ensure (jit_mod.funcs [index]));
50695081
5082+ func_ptr = addr;
50705083 jit_mod.funcs .emplace_back (addr);
50715084
50725085 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
51555168 {
51565169 if (func.size )
51575170 {
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+
51585176 const auto f = cast<Function>(_module->getOrInsertFunction (func.name , _func).getCallee ());
51595177 f->setCallingConv (CallingConv::GHC);
51605178 f->addParamAttr (1 , llvm::Attribute::NoAlias);
0 commit comments