Set optsize and minsize fun attributes for the -Os and -Oz optimization modes#16983
Open
ysbaddaden wants to merge 2 commits into
Open
Set optsize and minsize fun attributes for the -Os and -Oz optimization modes#16983ysbaddaden wants to merge 2 commits into
optsize and minsize fun attributes for the -Os and -Oz optimization modes#16983ysbaddaden wants to merge 2 commits into
Conversation
…on modes LLVM 23 removed the PassBuilder support for default<Os> and default<Oz> that was introduced in LLVM 17. We now use the default<O2> optimization level, and set the optsize (Os) or minsize (Oz) function attribute to every functions, which has the same behavior. Bonus: this enables support for -Oz and -Oz for LLVM 13-16.
optsize and minsize fun attributes for the -Os and -Oz optimization modes
Sija
reviewed
May 19, 2026
straight-shoota
approved these changes
May 20, 2026
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.
LLVM 23 removes the
PassBuildersupport fordefault<Os>anddefault<Oz>that was introduced in LLVM 17.Instead, we shall use the
default<O2>optimization level, and set theoptsize(-Os) orminsize(-Oz) function attribute to every functions, which has the same behavior. This in turn enables support for-Ozand-Ozfor LLVM 13 to 16.I manually tested against different LLVM versions (15, 18, 21 and 23):
-Osis smaller than any-O0to-O3level, and-Ozis even smaller.closes #16895
related to #14463