Repository navigation
Add five passes and resumable runs (--resume) - #4
Merged
Merged
Conversation
Rewrites that kept coming up when matching gta2_re functions by hand. cache_member reads member types from the declarations in the included headers (findFieldTypes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each candidate gets an index, and in random mode its own generator seeded from (seed, index), so -j 1 is deterministic and a run can continue from any index. A checkpoint (position, seed, counts, best candidate, hashes of the candidates tried) is written to the output dir every couple of seconds and on exit; --resume carries on from it if the function and search options are unchanged. Exhaustive mode replays the earlier candidates without compiling them, so a resumed run continues with exactly the ones that weren't scored. Candidate hashes use FNV-1a so they are stable across builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New passes (
src/passes_manual.cpp)These are rewrites that kept coming up when matching gta2_re functions by hand:
cache_member: reads a member path used in the function into a local first. It tries three forms:T c = p->f;,T& c = p->f;, and for a struct,T* c = &p->f;. It does this for all uses or just the first. The type comes from the member declarations in the source and the headers it includes (findFieldTypes, collected next to the getters). Names declared with two different types are skipped.ref_local: switches betweenT x = e;,const T& x = e;andT& x = e;. A named local gets its own stack slot, while a temporary bound to a reference may share one.incdec: switches betweenx++,++x,x += 1andx = x + 1, in expression statements and for-steps.cond_temp: computes anifcondition into ans32/u8/boollocal first.pow2_shift: switches betweenx * 4andx << 2, and turnsx / 4intox >> 2, including the compound forms. The two can differ for negative values, so check the diff before using a result.localTypesmoved out of the anonymous namespace so the new file can use it.docs/passes.mdis regenerated and has an example for each new pass.Resumable runs
-j 1a seed always gives the same candidates in the same order.--keep-prob). A resumed run still never repeats an index or a candidate it already tried.checkpoint.txt,checkpoint_best.txtandcheckpoint_seen.txtare written to the output dir every couple of seconds and on exit, including Ctrl-C. They hold the position, the seed, the counts, the best candidate and the hashes of the candidates already tried.--resume: carries on from the first candidate that wasn't scored.-p,--weight,--op-alias,--depth,--max-mutationsand--keep-prob.-ncounts only the new run's compiles;--max-candidatescounts the whole search.Tests
ctest.tests/integration/vc6.sh). The new passes were used against real VC6 through gta2_re'sScripts/permute.sh, which found matches forTrailer::sub_407BD0andgtx_0x106C::GetSpriteTrueIndex_5AA460. A resumed run tookMap_0x370::sub_4E6660from 48 diff lines to 4.local_typerandom integration run now accepts an equivalent match. With the new seeding, the fixed-seed run lands onunsigned long xinstead ofunsigned int x. They are the same type at i686 -O0, the same allowance the other passes with equivalent forms already have.🤖 Generated with Claude Code