Repository navigation
cmake: function-visibility.txt entries for the /GL units of #515, #516 and #518 - #534
Merged
Merged
Conversation
…d#515, sourcehold#516 and sourcehold#518 sourcehold#515, sourcehold#516 and sourcehold#518 put twelve units on cmake/compiler-flags-gl.txt. UpdateCamel, UpdateLady and UpdateFireEater have an entry here already and read 100.0% with OPENSHC_FUNCTION_VISIBILITY_UNITS on; the other nine have none. In that mode the members of every group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit without an entry no longer sees them: the nine read 37.7% to 65.7% in main ff7e56e's full build in that mode, the build the real builds below compare against. Each gets an entry at its address, its callees in address order. The /GL lines stay as they are. Each entry names only callees that are already members of the group that holds hasUnitReachedDestination, so the nine join that group and nothing else moves: no other function leaves the /GL list, and no other function sees a body it did not see before. The nine's other /GL callees (setDestinationForUnit, moveToFreeTileNearby, acquireShootTarget, shootProjectile and the rest of their closures) stay opaque to them, and they read 100.0% / 100.0% that way (raw / normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses). Naming each unit's whole /GL callee closure instead would put 28 more functions in that group: with every .cpp of main as the build list, cmake/function-visibility-units.py then makes 22 wrapper units holding 178 source files, against 25 holding 141 on main (the nine units and 28 of their callees join, and three smaller groups merge in). Those 28 would leave the /GL list for main's callers that have no entry (processUnitMove, exitLadder, unitClimbing, UpdateHorseArcher_DoShooting and others). Each caller-callee pair is measured as sourcehold#491's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone, quick_diff on main ff7e56e. The data resolvers were switched on with tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list with tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the group's members that the unit calls directly or through another member it calls (so indirect ones too: commitUnitLocation's two callees for UpdateTunneler, ConsiderHavingABreakNowUnk behind UpdateWorker_ConsiderTakingABreakUnk for UpdateWheatFarmer), not callees reached only through functions outside the group. A callee is listed when leaving it out of that set lowers the ratio; the listed set reads what the whole set reads. quick_diff is stricter than reccmp about register names; the real builds read each unit at 100.0%. - UpdateMother: 0.5668 alone, 0.9918 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7900, hasUnitReachedDestination 0.8918, changeDestinationByAmount 0.8994. - UpdateChild: 0.5564 alone, 0.9993 with its 4. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.8294, hasUnitReachedDestination 0.9153, hasTunnelerNotFinishedDigging 0.9881, changeDestinationByAmount 0.9976. - UpdateTunneler: 0.6433 alone, 0.9897 with its 2. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.7619, hasUnitReachedDestination 0.6726. commitUnitLocation and its callees setupUnitSharingCurrentTilePosition and setupUnitSharingTileIDs change nothing. - UpdateWheatFarmer: 0.4115 alone, 0.9988 with its 8. Left out, IncrementAndOptionalUpdateAVValueRelated reads 0.7775, ConsiderHavingABreakNowUnk 0.9838, SetStateToFreetimeWalking 0.9898, ComputeGoodsProduced 0.9784, checkIfCitizenUnitIsAliveBasedOnState 0.8193, hasUnitReachedDestination 0.9462, changeDestinationByAmount 0.9130, UpdateWorker_ConsiderTakingABreakUnk 0.9838. - UpdateCrusaderArcher: 0.6723 alone, 0.9869 with its 3. Left out, xyAreValid reads 0.9709, hasUnitReachedDestination 0.7176, changeDestinationByAmount 0.9853. - UpdateCrossbowman: 0.6537 alone, 0.9964 with hasUnitReachedDestination. - UpdateLadderman: 0.4106 alone, 0.9938 with hasUnitReachedDestination. - UpdateArabianArcher: 0.5843 alone, 0.9944 with hasUnitReachedDestination. - UpdateFireThrower: 0.6844 alone, 0.9965 with hasUnitReachedDestination. makeUnitStopWalkingByClearingPathProgressState, which UpdateMother, UpdateChild and UpdateWheatFarmer call, changes nothing for any of them. With every .cpp of main as the build list, cmake/function-visibility-units.py now makes 25 wrapper units holding 150 source files (141 before): the nine join the group that holds hasUnitReachedDestination, and no other file changes group. CMake reads this file only with the option on, so the default build is unchanged. Real builds of this change on main ff7e56e, BUILD_OK and 0 failures each: - full, option on: every .cpp of main with all function and data resolvers on (the 12 files that don't compile since sourcehold#509's sync left out), 3,025 files and 3,043 functions, against main ff7e56e built the same way. The nine read 100.0% / 100.0% (main: 37.7% to 65.7%); nothing else reads differently. - small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units and UpdatePriest with their callee closures, and every file of a group that touches them, 485 files and 495 functions. All twelve read 100.0% / 100.0% in both modes; UpdatePriest, which has no entry, 100.0% off and 72.0% / 68.9% on, as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 30, 2026
gynt
pushed a commit
to gynt/OpenSHC
that referenced
this pull request
Dec 2, 2026
…t and UpdateMiller (sourcehold#535) sourcehold#534 gave the nine /GL units of sourcehold#515, sourcehold#516 and sourcehold#518 that had no entry in cmake/function-visibility.txt one, and left three for a follow-up: UpdatePeasant and UpdateMiller (sourcehold#533), and UpdatePriest, main's own unit. This adds the three, each at its address, its callees in address order. All three are on cmake/compiler-flags-gl.txt already (UpdatePriest was there before those PRs); that file stays as it is. With OPENSHC_FUNCTION_VISIBILITY_UNITS on, the members of every group leave the /GL list, among them the helpers in the group that holds hasUnitReachedDestination, so a /GL unit without an entry no longer sees them: in main e62246a's full build in that mode, the build the real builds below compare against, UpdatePriest reads 72.0% / 68.9%, UpdatePeasant 49.3% / 48.7% and UpdateMiller 51.7% / 46.2% (raw / normalised: reccmp_report.py's normalised figure ignores call and tail-jump targets and resolver addresses). UpdatePriest's entry names only callees that are already members of the group that holds hasUnitReachedDestination, as sourcehold#534's do. UpdatePeasant's and UpdateMiller's name members of that group and, each, one more /GL callee that is not in it: getDestination2EqualsGivenCoordinates for UpdatePeasant and standUpIfSeated for UpdateMiller. With the members alone they read 96.0% / 87.1% and 96.5% / 93.0% in an earlier full build of this branch with the option on (below). With that callee they read 100.0%, so it joins the group, and with the option on, CMake takes five more files off the /GL list: the three units, getDestination2EqualsGivenCoordinates and standUpIfSeated. Nothing else moves: getDestination2EqualsGivenCoordinates is called by UpdatePeasant only, and standUpIfSeated by UpdateMiller, standUpAllTribeUnits and updatePeasantSeatingAtBuilding (neither of the last two is on the /GL list or has an entry, so neither saw its body before or sees it now). No other function sees a body it did not see before. The three units' other /GL callees (setDestinationForUnit, resetUnitMovementState, clearHiddenFlagAndUpdatePosition, setWorkplaceBuildingEntryAsTarget, selectNewBlessingTarget, setUnitFacingDirectionTowardsTarget and the rest of their closures) stay opaque to them. Each caller-callee pair is measured as sourcehold#491's and sourcehold#534's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone, quick_diff on main e62246a, with the data resolvers switched on by tools/reimplementation-control/enable_reimplemented_data.py and the function resolver of every .cpp in the build list by tools/reimplementation-helper/batch/enable_local_functions.py (locally, not committed). The callees tried are the group's members that the unit calls directly or through another member it calls (commitUnitLocation's callee setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs, included), not callees reached only through functions outside the group; and, for UpdatePeasant and UpdateMiller, each /GL callee outside the group that they call, one at a time on top of the named members, pasted without its own callees unless it says "with its callees". A callee is listed when leaving it out of the set lowers the ratio; the listed set reads what the whole set reads. quick_diff is stricter than reccmp about register names; the real builds read the units at 100.0%. - UpdatePriest: 0.7534 alone, 0.9986 with its 5. Left out, makeUnitStopWalkingByClearingPathProgressState reads 0.9891, IncrementAndOptionalUpdateAVValueRelated 0.8859, checkIfCitizenUnitIsAliveBasedOnState 0.9510, hasUnitReachedDestination 0.9680, changeDestinationByAmount 0.9850. commitUnitLocation, its callee setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs change nothing. - UpdatePeasant: 0.5329 alone, 0.9941 with its 3. Left out, checkIfCitizenUnitIsAliveBasedOnState reads 0.5880, getDestination2EqualsGivenCoordinates 0.9725, hasUnitReachedDestination 0.9684. Outside the group, on top of the two members, clearHiddenFlagAndUpdatePosition (with its callees) and setDestinationForUnit change nothing. - UpdateMiller: 0.5531 alone, 0.9973 with its 13. Left out, getBuildingResourceAmountByUid reads 0.9722, setupUnitSharingTileIDs 0.9947, standUpIfSeated 0.9913, sitDownIfStanding 0.9953, IncrementAndOptionalUpdateAVValueRelated 0.8442, ConsiderHavingABreakNowUnk 0.9914, SetStateToFreetimeWalking 0.9707, ComputeGoodsProduced 0.9661, checkIfCitizenUnitIsAliveBasedOnState 0.8008, hasUnitReachedDestination 0.9593, setupUnitSharingCurrentTilePosition 0.9947, UpdateWorker_ConsiderTakingABreakUnk 0.9914, commitUnitLocation 0.9947. makeUnitStopWalkingByClearingPathProgressState changes nothing. Outside the group, on top of the twelve members, resetUnitMovementState (with its callees), setDestinationForUnit, setWorkplaceBuildingEntryAsTarget, addResourceToStockpile, buildingIsAccessible, updateBuildingSignpostCounter and getStorageBuildingForResourceTypeAndAmount change nothing; the last four are members of other groups, so with the option on they are off the /GL list already, and naming one would merge two groups. With every .cpp of main as the build list, cmake/function-visibility-units.py makes 25 wrapper units holding 155 source files (150 before): the three units and the two callees join the group that holds hasUnitReachedDestination, and no other file changes group. CMake reads this file only with the option on, so the default build is unchanged. Real builds on main e62246a, BUILD_OK and 0 failures each: - full, option on: every .cpp of main with all function and data resolvers on (the 3 files that don't compile there left out: findBestAttackTileByPathCost, resetTileAndClearMoat, TransformAndRenderPercentage), 3,036 files and 3,054 functions, against main e62246a built the same way. Two full builds of the branch's side: one with the three entries without getDestination2EqualsGivenCoordinates and standUpIfSeated (UpdatePriest's as it is now), which reads UpdatePeasant 96.0% / 87.1%, UpdateMiller 96.5% / 93.0% and UpdatePriest 100.0% / 100.0%; and this change, which reads the three 100.0% / 100.0%. Against main nothing else reads differently in either. - small, both modes: main's /GL list, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units of sourcehold#515, sourcehold#516 and sourcehold#518 (nine in sourcehold#534, three with an entry before it) and these three with their callee closures, standUpAllTribeUnits and updatePeasantSeatingAtBuilding, and every file of a group that touches them, 494 files and 504 functions. All fifteen units read 100.0% / 100.0% in both modes. UpdateFireBallistaBuilding: with the option off, where this file is not read, 100.0% / 100.0% with the 494 files and 99.6% / 95.5% with 492 (without standUpAllTribeUnits and updatePeasantSeatingAtBuilding), so its reading changes with the set of files built; with the option on, 99.6% / 95.5% with the 494 files, and main was not built with those files and the option on, so that case is not settled. It reads 100.0% / 100.0% in both full builds, this change's and main's. 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.
#515, #516 and #518 put twelve Map::Units update functions on
cmake/compiler-flags-gl.txt, each at 100% in the default build. Three of them (UpdateCamel, UpdateLady, UpdateFireEater) already have an entry incmake/function-visibility.txtand read 100% withOPENSHC_FUNCTION_VISIBILITY_UNITSon. The other nine have none, and each of those PRs left their entries for a follow-up with its own full build in that mode. This is that follow-up: one commit,cmake/function-visibility.txtonly, an entry for each of the nine at its address, its callees in address order. No.cpp, header or/GLchange.Units::UpdateMothercheckIfCitizenUnitIsAliveBasedOnState,hasUnitReachedDestination,changeDestinationByAmountUnits::UpdateChildhasTunnelerNotFinishedDiggingUnits::UpdateTunnelercheckIfCitizenUnitIsAliveBasedOnState,hasUnitReachedDestinationUnits::UpdateWheatFarmerIncrementAndOptionalUpdateAVValueRelated,ConsiderHavingABreakNowUnk,SetStateToFreetimeWalking,ComputeGoodsProduced,checkIfCitizenUnitIsAliveBasedOnState,hasUnitReachedDestination,changeDestinationByAmount,UpdateWorker_ConsiderTakingABreakUnkUnits::UpdateCrusaderArcherxyAreValid,hasUnitReachedDestination,changeDestinationByAmountUnits::UpdateCrossbowmanhasUnitReachedDestinationUnits::UpdateLaddermanhasUnitReachedDestinationUnits::UpdateArabianArcherhasUnitReachedDestinationUnits::UpdateFireThrowerhasUnitReachedDestinationRaw / normalised reccmp figures with the option on, from the full builds below; "before" is main ff7e56e built the same way. Normalised is main's
reccmp_report.pyfigure, which ignores call and tail-jump targets and resolver addresses. With the option off, the default build, all twelve read 100.0% before and after.What the entries name
With the option on, every caller and callee joined by entries ends up in one group, each group is built as one wrapper unit that
#includes its members (without/GL), and the members leave the/GLlist. The unit helpers that main's unit entries name are in one such group, the group that holdshasUnitReachedDestination. A/GLunit without an entry stays on the/GLlist but no longer sees them, which is why the nine read 37.7% to 65.7%.Each entry names only callees that are already members of the group that holds
hasUnitReachedDestination, so the nine join that group and nothing else moves: no other function leaves the/GLlist, and no other function sees a body it didn't see before. Their other/GLcallees (setDestinationForUnit,moveToFreeTileNearby,acquireShootTarget,shootProjectileand the rest of their closures) stay out of the group and opaque to them, and the nine read 100.0% that way. Naming each unit's whole/GLcallee closure instead would put 28 more functions in that group: with every.cppof main as the build list,cmake/function-visibility-units.pythen makes 22 wrapper units holding 178 source files, against 25 holding 141 on main (the nine units and 28 of their callees join, and three smaller groups merge in). Those 28 would leave the/GLlist for callers on main that have no entry (processUnitMove,exitLadder,unitClimbing,UpdateHorseArcher_DoShootingand others).Each caller-callee pair is measured as #491's were: the unit's file compiled with the callee files pasted in front of it, against the unit alone (
quick_diff, on main ff7e56e, with the resolvers as in the setup line below). The callees tried are the group's members that the unit calls directly or through another member it calls (so indirect ones too:commitUnitLocation's two callees for UpdateTunneler,ConsiderHavingABreakNowUnkbehindUpdateWorker_ConsiderTakingABreakUnkfor UpdateWheatFarmer), not callees reached only through functions outside the group. A callee is named when leaving it out of that set lowers the ratio, and the named set reads what the whole set reads:hasUnitReachedDestination.makeUnitStopWalkingByClearingPathProgressState(UpdateMother, UpdateChild, UpdateWheatFarmer), andcommitUnitLocationwith its calleessetupUnitSharingCurrentTilePositionandsetupUnitSharingTileIDs(UpdateTunneler). They are in the group anyway, through other entries.quick_diffis stricter than reccmp about register names; the real builds read each of the nine at 100.0%.Measured.
Stronghold Crusader.exe(3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed: the data resolvers withtools/reimplementation-control/enable_reimplemented_data.py, the function resolver of every.cppin the build withtools/reimplementation-helper/batch/enable_local_functions.py), and sourcehold's reccmp (a86aceb03) with--resolve-wrapped-calls --ignore-security-cookie..cppof main but the 12 in the note below, with all function and data resolvers on, 3,025 files and 3,043 functions, 0 failures, once on this branch and once on main ff7e56e. Nothing on main reads differently: the only changes are the nine units, as in the table. Average 99.23% against 99.10%.cmake/function-visibility-units.pymakes 25 wrapper units holding 150 source files (141 on main): the nine join the group that holdshasUnitReachedDestination, and no other file changes group./GLfile of main, every.cppthat readsUnit::disappearFadeAlphaCountdown, the twelve units and main's UpdatePriest with their callee closures, and every file of a function-visibility group that touches them: 485 files, 495 functions, 0 failures in both modes./GLunit without an entry, reads 72.0% / 68.9%, as in main's builds.cmake/function-visibility.txtonly insideif(OPENSHC_FUNCTION_VISIBILITY_UNITS)(CMakeLists.txtline 148): the file is registered as a configure dependency and handed tocmake/function-visibility-units.pythere and nowhere else, so with the option off this branch builds exactly what main builds..cppor header change, sostyle_lint.pyhas nothing to check.renderDebugDataCurrentPlayerData,applyGateOrDrawbridgeOpenCloseChange,initializeGatePathfindingForOwner,updatePathLinkageTileMap,UpdateGateHouseLarge,UpdateGateHouseSmall,UpdateWoodGate1,findBestAttackTileByPathCost,resetTileAndClearMoat,GateOpenOrClose,ClickOpenOrCloseGate,TransformAndRenderPercentage). All the builds above left them out, with their resolvers off. This PR doesn't touch them.Left out
Other PRs
bool) touch neither this file nor any function named in it.🤖 Generated with Claude Code