@@ -4146,7 +4146,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
4146
4146
}
4147
4147
4148
4148
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] );
4150
4150
inc_fdone = 0 ;
4151
4151
}
4152
4152
});
@@ -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
{
@@ -4808,7 +4815,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
4808
4815
settings += ppu_settings::accurate_nj_mode, settings -= ppu_settings::fixup_nj_denormals, fmt::throw_exception (" NJ Not implemented" );
4809
4816
4810
4817
// 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 ));
4812
4819
}
4813
4820
4814
4821
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)
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
{
@@ -5054,12 +5063,29 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size)
5054
5063
break ;
5055
5064
}
5056
5065
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;
5058
5077
5059
5078
// 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
+ }
5062
5087
5088
+ func_ptr = addr;
5063
5089
jit_mod.funcs .emplace_back (addr);
5064
5090
5065
5091
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
5148
5174
{
5149
5175
if (func.size )
5150
5176
{
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
+
5151
5182
const auto f = cast<Function>(_module->getOrInsertFunction (func.name , _func).getCallee ());
5152
5183
f->setCallingConv (CallingConv::GHC);
5153
5184
f->addParamAttr (1 , llvm::Attribute::NoAlias);
@@ -5194,6 +5225,15 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
5194
5225
5195
5226
if (module_part.funcs [fi].size )
5196
5227
{
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
+
5197
5237
// Translate
5198
5238
if (const auto func = translator.Translate (module_part.funcs [fi]))
5199
5239
{
0 commit comments