We have an optimization pass which removes dummy hook implementations hook we do emit when users did not provide their own hook implementations. What we did not implement at the time was for that pass to also remove the triggering of the hook wrapper (the code which invokes the hook implementations) since at that time we did not compile code in a way where we could be certain that we would see all code.
This has changed in the meantime and we now compile in a mode where all relevant code needs to be visible.[^1] We should update the pass to also remove triggering of the hook wrapper. Since we perform a number not-free computations for each hook invocation with pre- and post-hook functions this could improve performance. To implement this we could naively wrap all hook-dependent code with in checks of hook-specific feature constant. Ideally we would not break the way hooks can be implemented in C++ code (both for public and non-public units).
[^1]: Caveat: We also need to see all C++ files, but currently cannot detect hook implementations in C++ code.
We have an optimization pass which removes dummy hook implementations hook we do emit when users did not provide their own hook implementations. What we did not implement at the time was for that pass to also remove the triggering of the hook wrapper (the code which invokes the hook implementations) since at that time we did not compile code in a way where we could be certain that we would see all code.
This has changed in the meantime and we now compile in a mode where all relevant code needs to be visible.[^1] We should update the pass to also remove triggering of the hook wrapper. Since we perform a number not-free computations for each hook invocation with pre- and post-hook functions this could improve performance. To implement this we could naively wrap all hook-dependent code with in checks of hook-specific feature constant. Ideally we would not break the way hooks can be implemented in C++ code (both for public and non-public units).
[^1]: Caveat: We also need to see all C++ files, but currently cannot detect hook implementations in C++ code.