-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Accept empty optimizer sequence with Yul optimizer disabled #14657
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -383,6 +383,25 @@ void OptimiserSuite::validateSequence(std::string_view _stepAbbreviations) | |||||||||||||||||||||||||||||||||||||||||
assertThrow(nestingLevel == 0, OptimizerException, "Unbalanced brackets"); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
bool OptimiserSuite::isEmptyOptimizerSequence(std::string const& _sequence) | ||||||||||||||||||||||||||||||||||||||||||
nikola-matic marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
size_t delimiterCount{0}; | ||||||||||||||||||||||||||||||||||||||||||
for (char const step: _sequence) | ||||||||||||||||||||||||||||||||||||||||||
switch (step) | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
case ':': | ||||||||||||||||||||||||||||||||||||||||||
if (++delimiterCount > 1) | ||||||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||||||||||||||
nikola-matic marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||
case ' ': | ||||||||||||||||||||||||||||||||||||||||||
case '\n': | ||||||||||||||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+387
to
+403
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, I'm very much fine with leaving this as is - but given that I think I even already saw some discussion in the channel around this on the side, I can't help but wonder: why the special handling of different counts of colons in here and all the fuzz (the sequence will separately be validated and arguably it even makes more sense to treat This could just be (inline):
Suggested change
in one case - and in the second case for standard json even simpler... |
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
void OptimiserSuite::runSequence(std::string_view _stepAbbreviations, Block& _ast, bool _repeatUntilStable) | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
validateSequence(_stepAbbreviations); | ||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.0; | ||
|
||
contract C { | ||
function f() public pure {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"language": "Solidity", | ||
"sources": { | ||
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_no_yul/in.sol"]} | ||
}, | ||
"settings": { | ||
"optimizer": { | ||
"details": { | ||
"yul": false, | ||
"yulDetails": { | ||
"optimizerSteps": "u:fdntOc" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"errors": | ||
[ | ||
{ | ||
"component": "general", | ||
"formattedMessage": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted.", | ||
"message": "If Yul optimizer is disabled, only an empty optimizerSteps sequence is accepted.", | ||
"severity": "error", | ||
"type": "JSONError" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.0; | ||
|
||
contract C { | ||
function f() public pure {} | ||
} | ||
nikola-matic marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"language": "Solidity", | ||
"sources": { | ||
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_empty_sequence_no_yul/in.sol"]} | ||
}, | ||
"settings": { | ||
"optimizer": { | ||
"details": { | ||
"yul": false, | ||
"yulDetails": { | ||
"optimizerSteps": ":" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"sources": | ||
{ | ||
"A": | ||
{ | ||
"id": 0 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.0; | ||
|
||
contract C { | ||
function f() public pure {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"language": "Solidity", | ||
"sources": { | ||
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_whitespace_newline_sequence_no_yul/in.sol"]} | ||
}, | ||
"settings": { | ||
"optimizer": { | ||
"details": { | ||
"yul": false, | ||
"yulDetails": { | ||
"optimizerSteps": "\n : " | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"sources": | ||
{ | ||
"A": | ||
{ | ||
"id": 0 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Error: --yul-optimizations is invalid if Yul optimizer is disabled | ||
Error: --yul-optimizations is invalid with a non-empty sequence if Yul optimizer is disabled. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--ir-optimized --metadata --yul-optimizations : |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Warning: Unused local variable. | ||
--> yul_optimizer_steps_without_optimize_empty_sequence/input.sol:13:9: | ||
| | ||
13 | uint b = a; | ||
| ^^^^^^ | ||
|
||
Warning: Unused local variable. | ||
--> yul_optimizer_steps_without_optimize_empty_sequence/input.sol:14:9: | ||
| | ||
14 | uint c = a; | ||
| ^^^^^^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.0; | ||
|
||
contract C | ||
{ | ||
constructor() {} | ||
|
||
function foo() public pure returns (bool) | ||
{ | ||
// given the empty optimizer sequence ``:``, ``b`` and ``c`` should not be removed in the | ||
// optimized IR as the ``UnusedPruner`` step will not be run. | ||
uint a = 100; | ||
uint b = a; | ||
uint c = a; | ||
nikola-matic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return a == 100; | ||
} | ||
} |
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.