Skip to content
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

Fix custom cleanup sequence missing from metadata when other optimizer settings have default values #15859

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

clonker
Copy link
Member

@clonker clonker commented Feb 13, 2025

Extracted from PR #15834, see #15834 (comment).

The previous implementation did not make use of the yulOptimiserCleanupSteps. As @cameel suspected, providing a custom cleanup sequence under the default optimization sequence previously simply yielded a "optimizer": "enabled":true, "runs": 200} which potentially (or: most likely) doesn't reproduce the original compilation results.

I think it is a bit mitigated by there not being a specific field for the cleanup sequence in the standard-json input but one would rather have to reproduce the entire default optimization sequence, add a colon, and then modify the cleanup sequence.

@cameel
Copy link
Member

cameel commented Feb 13, 2025

This needs a changelog entry and a regression test that reproduces it.

Also, pinging @kuzdogan. Sourcify may need a workaround for this.

We should check which versions are affected (I guess it was introduced along with the cleanup sequence?).

@cameel cameel changed the title Default comparison operators for frontend optimiser settings Fix custom cleanup sequence missing from metadata when other optimizer settings have default values Feb 13, 2025
@clonker clonker force-pushed the fix_comparison_operators_for_optimizer_settings branch from 7aaf41b to cc03b19 Compare February 13, 2025 14:13
@clonker
Copy link
Member Author

clonker commented Feb 13, 2025

We should check which versions are affected (I guess it was introduced along with the cleanup sequence?).

The setting was introduced in v0.8.18 (including it not being part of operator==, PR #13376).
But actually the bug first occurs in v0.8.26 - probably due to some refactoring in correspondence to the metadata output of the optimization settings and in that, relying on the bad comparison operators. I initially failed to take into account that the default sequence changed. It is indeed broken since it has been introduced in v0.8.18.

@clonker clonker force-pushed the fix_comparison_operators_for_optimizer_settings branch from cc03b19 to 8e704f5 Compare February 13, 2025 14:45
@clonker clonker force-pushed the fix_comparison_operators_for_optimizer_settings branch from 8e704f5 to c1c10ac Compare February 13, 2025 15:19
"yulDetails": {
// default optimization sequence with a custom (truncated) cleanup sequence.
// 0.8.18 - 0.8.28 this would spuriously be interpreted as defaulted optimizer settings in metadata.
"optimizerSteps": "dhfoDgvulfnTUtnIf[xa[r]EscLMcCTUtTOntnfDIulLculVcul [j]Tpeulxa[rul]xa[r]cLgvifCTUca[r]LSsTFOtfDnca[r]Iulc]jmul[jul] VcTOcul jmul:D"
Copy link
Member Author

@clonker clonker Feb 13, 2025

Choose a reason for hiding this comment

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

I don't like this test so much actually. We won't regress if the default sequence changes at some point and it goes unnoticed to update it here as well. Something more elaborate would be first asserting that with the correct sequence it does produce default output and then truncating it in one of these ~-prefixed tests...

Copy link
Member

Choose a reason for hiding this comment

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

Another option would be to add this case to boost-based metadata tests:

std::vector<std::tuple<std::string, std::string>> sequences =
{
// {"<optimizer sequence>", "<optimizer cleanup sequence>"}
{"", ""},
{"", "fDn"},
{"dhfoDgvulfnTUtnIf", "" },
{"dhfoDgvulfnTUtnIf", "fDn"}
};

There you can refer to OptimiserSettings and the default sequence without hard-coding it.

@@ -13,6 +13,7 @@ Compiler Features:

Bugfixes:
* General: Fix internal compiler error when requesting IR AST outputs for interfaces and abstract contracts.
* Metadata: Fix custom cleanup sequence missing from metadata when other optimizer settings have default values
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Metadata: Fix custom cleanup sequence missing from metadata when other optimizer settings have default values
* Metadata: Fix custom cleanup sequence missing from metadata when other optimizer settings have default values.

"yulDetails": {
// default optimization sequence with a custom (truncated) cleanup sequence.
// 0.8.18 - 0.8.28 this would spuriously be interpreted as defaulted optimizer settings in metadata.
"optimizerSteps": "dhfoDgvulfnTUtnIf[xa[r]EscLMcCTUtTOntnfDIulLculVcul [j]Tpeulxa[rul]xa[r]cLgvifCTUca[r]LSsTFOtfDnca[r]Iulc]jmul[jul] VcTOcul jmul:D"
Copy link
Member

Choose a reason for hiding this comment

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

Another option would be to add this case to boost-based metadata tests:

std::vector<std::tuple<std::string, std::string>> sequences =
{
// {"<optimizer sequence>", "<optimizer cleanup sequence>"}
{"", ""},
{"", "fDn"},
{"dhfoDgvulfnTUtnIf", "" },
{"dhfoDgvulfnTUtnIf", "fDn"}
};

There you can refer to OptimiserSettings and the default sequence without hard-coding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants