-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Fix O(n²) in VarNameCleaner::findCleanName using per-base-name counter #16563
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e0fbdd0
Fix O(n²) in VarNameCleaner::findCleanName using per-base-name counter
msooseth 7b976b0
Update libyul/optimiser/VarNameCleaner.cpp
msooseth ca90aee
No need for mutable, Remove flaky tests
msooseth f040e42
Cleaner changelog
msooseth 5d66e17
Fixing
msooseth 6789d7e
Revert "No need for mutable, Remove flaky tests"
msooseth 0108682
Fixing
msooseth 69b488f
Fixing
msooseth 2ee692d
Update libyul/optimiser/VarNameCleaner.cpp
msooseth 2a24a9c
Fix const
msooseth 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
test/libyul/yulOptimizerTests/varNameCleaner/double_underscore_suffix.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| let x__1 := 1 | ||
| let x__2 := 2 | ||
| let x___3 := 3 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // } | ||
| // } |
25 changes: 25 additions & 0 deletions
25
test/libyul/yulOptimizerTests/varNameCleaner/interleaved_bases.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| let x_5 := 1 | ||
| let y_3 := 2 | ||
| let x_10 := 3 | ||
| let y_7 := 4 | ||
| let z_1 := 5 | ||
| let x_20 := 6 | ||
| let y_15 := 7 | ||
| let z_8 := 8 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let y := 2 | ||
| // let x_1 := 3 | ||
| // let y_1 := 4 | ||
| // let z := 5 | ||
| // let x_2 := 6 | ||
| // let y_2 := 7 | ||
| // let z_1 := 8 | ||
| // } | ||
| // } |
25 changes: 25 additions & 0 deletions
25
test/libyul/yulOptimizerTests/varNameCleaner/many_same_base.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| let x_10 := 1 | ||
| let x_20 := 2 | ||
| let x_30 := 3 | ||
| let x_40 := 4 | ||
| let x_50 := 5 | ||
| let x_60 := 6 | ||
| let x_70 := 7 | ||
| let x_80 := 8 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // let x_3 := 4 | ||
| // let x_4 := 5 | ||
| // let x_5 := 6 | ||
| // let x_6 := 7 | ||
| // let x_7 := 8 | ||
| // } | ||
| // } |
29 changes: 29 additions & 0 deletions
29
test/libyul/yulOptimizerTests/varNameCleaner/many_same_base_in_function.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| { | ||
| let x_1 := 1 | ||
| function f() | ||
| { | ||
| let x_10 := 1 | ||
| let x_20 := 2 | ||
| let x_30 := 3 | ||
| let x_40 := 4 | ||
| let x_50 := 5 | ||
| } | ||
| let x_2 := 2 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // } | ||
| // function f() | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // let x_3 := 4 | ||
| // let x_4 := 5 | ||
| // } | ||
| // } |
17 changes: 17 additions & 0 deletions
17
test/libyul/yulOptimizerTests/varNameCleaner/nested_suffixes.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| let x_1_2 := 1 | ||
| let x_3_4_5 := 2 | ||
| let x_6 := 3 | ||
| let x_1_2_3_4 := 4 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // let x_3 := 4 | ||
| // } | ||
| // } |
15 changes: 15 additions & 0 deletions
15
test/libyul/yulOptimizerTests/varNameCleaner/references_after_rename.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| let x_5 := 42 | ||
| let y_3 := x_5 | ||
| let z_1 := add(x_5, y_3) | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 42 | ||
| // let y := x | ||
| // let z := add(x, y) | ||
| // } | ||
| // } |
19 changes: 19 additions & 0 deletions
19
test/libyul/yulOptimizerTests/varNameCleaner/same_base_with_gap.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| let x := 1 | ||
| let x_1 := 2 | ||
| let x_5 := 3 | ||
| let x_10 := 4 | ||
| let x_20 := 5 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // let x_3 := 4 | ||
| // let x_4 := 5 | ||
| // } | ||
| // } |
20 changes: 20 additions & 0 deletions
20
test/libyul/yulOptimizerTests/varNameCleaner/suffix_skips_function_name.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| // x_1 is a function name, so the suffix counter must skip it | ||
| // when cleaning x_100 and x_200 which both strip to "x" | ||
| function x_1() {} | ||
| let x := 1 | ||
| let x_100 := 2 | ||
| let x_200 := 3 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_2 := 2 | ||
| // let x_3 := 3 | ||
| // } | ||
| // function x_1() | ||
| // { } | ||
| // } |
19 changes: 19 additions & 0 deletions
19
test/libyul/yulOptimizerTests/varNameCleaner/suffix_skips_reserved.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| let x := 1 | ||
| let x_2 := 2 | ||
| let x_100 := 3 | ||
| let x_200 := 4 | ||
| let x_300 := 5 | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // let x_3 := 4 | ||
| // let x_4 := 5 | ||
| // } | ||
| // } |
32 changes: 32 additions & 0 deletions
32
test/libyul/yulOptimizerTests/varNameCleaner/two_functions_same_base.yul
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| function f() | ||
| { | ||
| let x_10 := 1 | ||
| let x_20 := 2 | ||
| let x_30 := 3 | ||
| } | ||
| function g() | ||
| { | ||
| let x_40 := 4 | ||
| let x_50 := 5 | ||
| let x_60 := 6 | ||
| } | ||
| } | ||
| // ---- | ||
| // step: varNameCleaner | ||
| // | ||
| // { | ||
| // { } | ||
| // function f() | ||
| // { | ||
| // let x := 1 | ||
| // let x_1 := 2 | ||
| // let x_2 := 3 | ||
| // } | ||
| // function g() | ||
| // { | ||
| // let x := 4 | ||
| // let x_1 := 5 | ||
| // let x_2 := 6 | ||
| // } | ||
| // } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i interpret everything correctly, this is supposed to increment the suffix in the map, right? but I don't think it does, it's retrieved by value so the map value isnt updated, ever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'm sorry. It was written correctly and then broken. in 4b13837
Fixing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha some idiot probably suggested removing the reference. Wait a minute...