Skip to content

cmake: function-visibility.txt entries for UpdatePriest, UpdatePeasant and UpdateMiller - #535

Merged
gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-visibility2-100
Dec 1, 2026
Merged

gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:reimpl/units-A-visibility2-100

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

#534 gave the nine /GL units of #515, #516 and #518 that had no entry in cmake/function-visibility.txt one, and left three for this follow-up: UpdatePeasant and UpdateMiller (#533), and UpdatePriest. All three are on cmake/compiler-flags-gl.txt already; UpdatePriest was there before those PRs and is in none of them, and it is here because #534 left it and its entry is of the same kind as the others. One commit, cmake/function-visibility.txt only: an entry for each of the three at its address, its callees in address order. No change to a .cpp, a header or cmake/compiler-flags-gl.txt.

Function Address PR Option on, before -> after Callees named
Units::UpdatePeasant 0x0053EAA0 #533 49.3% / 48.7% -> 100.0% / 100.0% checkIfCitizenUnitIsAliveBasedOnState, getDestination2EqualsGivenCoordinates, hasUnitReachedDestination
Units::UpdateMiller 0x00554CC0 #533 51.7% / 46.2% -> 100.0% / 100.0% getBuildingResourceAmountByUid, setupUnitSharingTileIDs, standUpIfSeated, sitDownIfStanding, IncrementAndOptionalUpdateAVValueRelated, ConsiderHavingABreakNowUnk, SetStateToFreetimeWalking, ComputeGoodsProduced, checkIfCitizenUnitIsAliveBasedOnState, hasUnitReachedDestination, setupUnitSharingCurrentTilePosition, UpdateWorker_ConsiderTakingABreakUnk, commitUnitLocation
Units::UpdatePriest 0x00566750 none 72.0% / 68.9% -> 100.0% / 100.0% makeUnitStopWalkingByClearingPathProgressState, IncrementAndOptionalUpdateAVValueRelated, checkIfCitizenUnitIsAliveBasedOnState, hasUnitReachedDestination, changeDestinationByAmount

Raw / normalised reccmp figures with the option on, from the full builds below; "before" is main e62246a built the same way. Normalised is main's reccmp_report.py figure, which ignores call and tail-jump targets and resolver addresses. With the option off, the default build, all three read 100.0% in this branch's small build.

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 /GL list. The unit helpers that main's unit entries name are in one such group, the group that holds hasUnitReachedDestination. A /GL unit without an entry stays on the /GL list but no longer sees them, which is why the three read 49.3% to 72.0%.

UpdatePriest's entry names only callees that are already members of the group that holds hasUnitReachedDestination, as #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 (in Measured 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, and the full builds below show it. getDestination2EqualsGivenCoordinates is called by UpdatePeasant only. standUpIfSeated is called 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 didn't see before. The three units' other /GL callees (setDestinationForUnit, resetUnitMovementState, clearHiddenFlagAndUpdatePosition, setWorkplaceBuildingEntryAsTarget, selectNewBlessingTarget, setUnitFacingDirectionTowardsTarget and the rest of their closures) stay out of the group and opaque to them.

Each caller-callee pair is measured as #491's and #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 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 (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 the text says "with its callees". A callee is named when leaving it out of the set lowers the ratio, and the named set reads what the whole set reads:

  • UpdatePeasant 0.5329 alone, 0.9941 with its three; UpdateMiller 0.5531, 0.9973 with its thirteen; UpdatePriest 0.7534, 0.9986 with its five.
  • Not named because leaving it out changes nothing: makeUnitStopWalkingByClearingPathProgressState (UpdateMiller), and commitUnitLocation, its callee setupUnitSharingCurrentTilePosition and, behind it, setupUnitSharingTileIDs (UpdatePriest). They are in the group anyway, through other entries.
  • Outside the group, on top of the group members named, changing nothing: clearHiddenFlagAndUpdatePosition (with its callees) and setDestinationForUnit (UpdatePeasant); resetUnitMovementState (with its callees), setDestinationForUnit, setWorkplaceBuildingEntryAsTarget, addResourceToStockpile, buildingIsAccessible, updateBuildingSignpostCounter and getStorageBuildingForResourceTypeAndAmount (UpdateMiller). 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.
  • The commit message gives what each named callee reads when left out. quick_diff is stricter than reccmp about register names; the real builds read each of the three at 100.0%.

Measured.

  • Setup: the bundled MSVC1400-SP1 against the Steam Stronghold Crusader.exe (3bb0a8c1…5387ac5a), both resolver sets enabled locally (not committed: the data resolvers with tools/reimplementation-control/enable_reimplemented_data.py, the function resolver of every .cpp in the build with tools/reimplementation-helper/batch/enable_local_functions.py), and sourcehold's reccmp (a86aceb03) with --resolve-wrapped-calls --ignore-security-cookie.
  • Full builds, option on: every .cpp of main but the 3 in the note below, with all function and data resolvers on, 3,036 files and 3,054 functions, BUILD_OK and 0 failures each: main e62246a, and two full builds of the branch's side. The first of those had the three entries without getDestination2EqualsGivenCoordinates and standUpIfSeated (UpdatePriest's as it is now): UpdatePeasant 96.0% / 87.1%, UpdateMiller 96.5% / 93.0%, UpdatePriest 100.0% / 100.0%. The second is this branch. Against main, nothing on main reads differently in either: the only changes are the three units, as in the table for the second. Average 99.24% for this branch against 99.20% for main. cmake/function-visibility-units.py makes 25 wrapper units holding 155 source files (150 on main): the three units and the two callees join the group that holds hasUnitReachedDestination, and no other file changes group.
  • Small builds, both modes, of this branch on main e62246a: every /GL file of main, every .cpp that reads Unit::disappearFadeAlphaCountdown, the twelve units of Reimplement UpdateCamel, UpdateLady, UpdateMother and UpdateFireEater from gynt's units branch, under /GL (100%) #515, Reimplement UpdateChild, UpdateWheatFarmer, UpdateCrossbowman, UpdateLadderman, UpdateTunneler and UpdateFireThrower from gynt's units branch, under /GL (100%) #516 and Reimplement UpdateArabianArcher and UpdateCrusaderArcher from gynt's units branch, under /GL (100%) #518 (nine in cmake: function-visibility.txt entries for the /GL units of #515, #516 and #518 #534, three with an entry before it) and these three with their callee closures, standUpAllTribeUnits and updatePeasantSeatingAtBuilding (the other callers of standUpIfSeated), and every file of a function-visibility group that touches them: 494 files, 504 functions, 0 failures in both modes.
    • All fifteen units read 100.0% / 100.0% in both modes.
    • UpdateFireBallistaBuilding: with the option off, where cmake/function-visibility.txt is not read, it reads 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 it reads 99.6% / 95.5% with the 494 files; 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 branch's and main's.
  • Option off, full build: not run. CMake reads cmake/function-visibility.txt only inside if(OPENSHC_FUNCTION_VISIBILITY_UNITS) (CMakeLists.txt line 148): the file is registered as a configure dependency and handed to cmake/function-visibility-units.py there and nowhere else, so with the option off this branch builds exactly what main builds.
  • Checks: there is no .cpp or header change, so style_lint.py has nothing to check.
  • Not run in game.
  • Note: main e62246a has 3 files that don't compile (findBestAttackTileByPathCost, resetTileAndClearMoat, TransformAndRenderPercentage). cmake: function-visibility.txt entries for the /GL units of #515, #516 and #518 #534's text listed 12; the other nine compile on this main and are in the full builds. The builds above left the three out, with their resolvers off. This PR doesn't touch them.

Other PRs

🤖 Generated with Claude Code

…t and UpdateMiller

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants