Fixes -o:size - #7440
Merged
Merged
Conversation
Contributor
Author
|
Looks like Intel based CI test failures are unrelated and come from #7434 |
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 -o:size optimization level currently doesn't work, it occasionally produces code bigger than o:speed.
This PR fixes it by adding the optsize attribute per procedure at this optimization level. Optsize is then consulted by most of the passes.
On Linux, x64, default target, -o:size, LLVM 22, compiling examples/demo.odin I get
or around 27% smaller code and around 17% smaller binary.
Note that one of the tests (union_in_aggregates in tests/internal/test_union_const.odin) segfaults at -o:size (Linux, x64, default target (SSE), LLVM 22) due to hitting one of the compiler's alignment bugs. On my pc the test is working by accident at o:speed, -o:minimal and -o:none (an align-1 alloca's (u in the test) field happens to land at alignment 16 (type alignment required and assumed for indirect args), which satisfies the movdqa instruction issued, but -o:size happens to change the stack layout and the same align-1alloca lands at alignment 8, causing the segfault). This bug is fixed in #7382 by copying underaligned indirect args to aligned temp before passing.