Repository navigation
Add --extern-globals: try a global's definition as extern and back - #5
Merged
Merged
Conversation
Each global the target function names gets a region holding its declaration line in the source file: a DEFINE_GLOBAL... definition can become its EXTERN_GLOBAL declaration, and an extern can become its definition, copied from another .cpp in the same directory. VC6 can code a read of a global defined in the same file differently (gta2_re: 32-bit loads of a 2-byte global). Exhaustive mode tries each switch, random mode switches a global in one mutation in eight. 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.
VC6 can code a read of a global differently depending on whether the file defines it or only declares it
extern. In gta2_re, a 2-byte global defined in the same file got 32-bit loads. The original's 16-bit loads came back once the definition moved to another file:Weapon_30::dual_pistol_5DDA70matched, and fourWolfy_30functions went from 181 and 226 diff lines to 32 and 20.What
--extern-globalsdoesRegion::altholds the other form.DEFINE_GLOBAL...(type, name, ...), can becomeEXTERN_GLOBAL(type, name);, orEXTERN_GLOBAL_ARRAY(type, name, size);for arrays.--global-macros DEFINE=EXTERNnames other macros with the same argument layout. The default is gta2_re'sFunction.hppmacros.extern_globalin the stats).Tests
extern_global,--dry-run): the definition gets an extern candidate, the extern gets the definition fromother.cpp, and a global the function doesn't read isn't offered. clang codes both forms the same, so the case checks the candidates, not a match.ctest.word_706D5E's definition was put back intoWeapon_30.cpp, sodual_pistol_5DDA70scored 245.-m exhaustive -p incdec --extern-globals.+EXTERN_GLOBAL(Ang16, word_706D5E);.🤖 Generated with Claude Code