Skip to content

Mark functions as NORETURN #10260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged

Mark functions as NORETURN #10260

merged 3 commits into from
Apr 16, 2025

Conversation

jepler
Copy link

@jepler jepler commented Apr 16, 2025

Surprisingly this leads to some code size savings on itsybitsym4, even though LTO optimization should have let the compiler deduce (almost) all of this.

When a compiler knows a call can never return, it is possibly able to avoid emitting code, such as saving caller-saved registers to the stack, or doing ANYTHING affter the function returns, explaining why code size savings is possible with this attribute.

With the exception of raise_deinited_error, these were found by checking the functions found by -Wmissing-noreturn and making a case by case decision. However, this dignostic can't be enabled unconditionally as it has false positives, functions we do NOT want to mark as noreturn.

Testing performed: built itsybitsy m4, flash size savings 128 bytes. I didn't test on hardware as none came on this trip with me.

jepler added 3 commits April 16, 2025 16:57
Surprisingly this leads to some code size savings on itsybitsym4,
even though LTO optimization should have let the compiler deduce
(almost) all of this.

When a compiler knows a call can never return, it is possibly able
to avoid emitting code, such as saving caller-saved registers to the
stack, or doing _ANYTHING_ affter the function returns, explaining
why code size savings is possible with this attribute.

With the exception of raise_deinited_error, these were found by checking
the functions found by `-Wmissing-noreturn` and making a case by case
decision. However, this dignostic can't be enabled unconditionally as it
has false positives, functions we do NOT want to mark as noreturn.

Testing performed: built itsybitsy m4, flash size savings 128 bytes.
didn't test on hardware as none came on this trip with me.
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit 29018ad into adafruit:main Apr 16, 2025
22 checks passed
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