Skip to content

[Strings] Add a string-builtins feature, and lift/lower automatically when enabled #7601

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
work
  • Loading branch information
kripken committed May 15, 2025
commit 36d89d5c53fd4903076ba6c08b5aac9ed8e5f8e5
23 changes: 21 additions & 2 deletions src/tools/optimization-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,21 @@ struct OptimizationOptions : public ToolOptions {
passRunner.clear();
};

for (auto& pass : passes) {
// Find the first and last default opt passes, so we can tell them they are
// first/last.
Index firstDefault = -1;
Index lastDefault = -1;
for (Index i = 0; i < passes.size(); i++) {
if (passes[i].name == DEFAULT_OPT_PASSES) {
if (firstDefault == -1) {
firstDefault = i;
}
lastDefault = i;
}
}

for (Index i = 0; i < passes.size(); i++) {
auto& pass = passes[i];
if (pass.name == DEFAULT_OPT_PASSES) {
// This is something like -O3 or -Oz. We must run this now, in order to
// set the proper opt and shrink levels. To do that, first reset the
Expand All @@ -416,8 +430,13 @@ struct OptimizationOptions : public ToolOptions {
passRunner.options.optimizeLevel = *pass.optimizeLevel;
passRunner.options.shrinkLevel = *pass.shrinkLevel;

// Note the ordering of these default passes.
PassRunner::Ordering ordering;
ordering.first = (i == firstDefault);
ordering.last = (i == lastDefault);
Comment on lines +432 to +434
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively:

Suggested change
PassRunner::Ordering ordering;
ordering.first = (i == firstDefault);
ordering.last = (i == lastDefault);
PassRunner::Ordering ordering{i == firstDefault, i == lastDefault};
Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of like writing out which is first and which is last? I guess the natural order is (first, last) but it is still easier to read I think.


// Run our optimizations now with the custom levels.
passRunner.addDefaultOptimizationPasses();
passRunner.addDefaultOptimizationPasses(ordering);
flush();

// Restore the default optimize/shrinkLevels.
Expand Down