@@ -4146,7 +4146,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
41464146 }
41474147
41484148 ppu_log.notice (" Failed to precompile '%s' (prx: %s, ovl: %s): Attempting tratment as executable file" , path, prx_err, ovl_err);
4149- possible_exec_file_paths.push (path, offset, file_size );
4149+ possible_exec_file_paths.push (file_queue[func_i] );
41504150 inc_fdone = 0 ;
41514151 }
41524152 });
@@ -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 {
@@ -4808,7 +4815,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
48084815 settings += ppu_settings::accurate_nj_mode, settings -= ppu_settings::fixup_nj_denormals, fmt::throw_exception (" NJ Not implemented" );
48094816
48104817 // Write version, hash, CPU, settings
4811- fmt::append (obj_name, " v6 -kusa-%s-%s-%s.obj" , fmt::base57 (output, 16 ), fmt::base57 (settings), jit_compiler::cpu (g_cfg.core .llvm_cpu ));
4818+ fmt::append (obj_name, " v7 -kusa-%s-%s-%s.obj" , fmt::base57 (output, 16 ), fmt::base57 (settings), jit_compiler::cpu (g_cfg.core .llvm_cpu ));
48124819 }
48134820
48144821 if (cpu ? cpu->state .all_of (cpu_flag::exit) : Emu.IsStopped ())
@@ -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 {
@@ -5054,12 +5063,29 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
50545063 break ;
50555064 }
50565065
5057- const auto name = fmt::format (" __0x%x" , func.addr - reloc);
5066+ u32 og_func = func.addr ;
5067+
5068+ if (auto it = info.duplicate_map .find (func.addr ); it != info.duplicate_map .end ())
5069+ {
5070+ og_func = it->second ;
5071+ }
5072+
5073+ const auto name = fmt::format (" __0x%x" , og_func - reloc);
5074+
5075+ ppu_intrp_func_t dummy{};
5076+ ppu_intrp_func_t & func_ptr = is_first ? func_ptr_map[name] : dummy;
50585077
50595078 // Try to locate existing function if it is not the first time
5060- const auto addr = is_first ? ensure (reinterpret_cast <ppu_intrp_func_t >(jit->get (name)))
5061- : reinterpret_cast <ppu_intrp_func_t >(ensure (jit_mod.funcs [index]));
5079+ const auto addr = is_first ? (func_ptr ? func_ptr : (reinterpret_cast <ppu_intrp_func_t >(jit->get (name))))
5080+ : reinterpret_cast <ppu_intrp_func_t >(jit_mod.funcs [index]);
5081+
5082+ if (!addr)
5083+ {
5084+ ppu_log.fatal (" Failed to retrieve symbol address at 0x%x (duplicate=0x%x)" , func.addr , info.duplicate_map .contains (func.addr ) ? og_func : 0 );
5085+ ensure (addr);
5086+ }
50625087
5088+ func_ptr = addr;
50635089 jit_mod.funcs .emplace_back (addr);
50645090
50655091 if (func.size == 4 && !BLR_func && *info.get_ptr <u32 >(func.addr ) == ppu_instructions::BLR ())
@@ -5148,6 +5174,11 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
51485174 {
51495175 if (func.size )
51505176 {
5177+ if (auto it = module_part.duplicate_map .find (func.addr ); it != module_part.duplicate_map .end () && it->second != it->first )
5178+ {
5179+ continue ;
5180+ }
5181+
51515182 const auto f = cast<Function>(_module->getOrInsertFunction (func.name , _func).getCallee ());
51525183 f->setCallingConv (CallingConv::GHC);
51535184 f->addParamAttr (1 , llvm::Attribute::NoAlias);
@@ -5194,6 +5225,15 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
51945225
51955226 if (module_part.funcs [fi].size )
51965227 {
5228+ const u32 faddr = module_part.funcs [fi].addr ;
5229+ auto it = module_part.duplicate_map .find (faddr);
5230+
5231+ if (it != module_part.duplicate_map .end () && it->second != faddr)
5232+ {
5233+ ppu_log.trace (" LLVM: Function 0x%x was skipped (duplicate)" , faddr);
5234+ continue ;
5235+ }
5236+
51975237 // Translate
51985238 if (const auto func = translator.Translate (module_part.funcs [fi]))
51995239 {
0 commit comments