Repository navigation
fix: reduce on_entry/on_exit code bloat at -Oz on ARM - #743
Merged
kris-jusiak merged 1 commit intoNov 7, 2026
Merged
Conversation
The entry/exit dispatch chain (process_internal_event → process_internal_generic_event → process_event_impl → switch_stm::dispatch) instantiates per event type. At -O2 these inline away; at -Oz the lower inline threshold keeps each as a separate function, tripling .text on cortex-m0. Mark the chain BOOST_SML_DETAIL_ALWAYS_INLINE (__attribute__((always_inline)) / __forceinline) so the optimizer folds them regardless of -Oz threshold. Measured on clang 23, --target=arm-arm-none-eabi -mcpu=cortex-m0 -Oz: .text with on_entry/on_exit: 2343 → 1321 bytes (−44%) .text without entry/exit: 701 → 701 (no regression) -O2 / -Os: unchanged Closes boost-ext#494
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.
The entry/exit dispatch chain instantiates per event type. At -O2 everything inlines away, but at -Oz the lower inline threshold keeps each instantiation as a separate function — on cortex-m0 this triples .text vs a hand-written equivalent.
Adds
BOOST_SML_DETAIL_ALWAYS_INLINE(__attribute__((always_inline))/__forceinline) to the five functions in the chain:switch_stm::dispatch,process_internal_generic_event,process_internal_event,process_event_impl.Measured on clang 23,
--target=arm-arm-none-eabi -mcpu=cortex-m0 -Oz:11 lines changed, no new files or dependencies.
Closes #494