mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not overwrite allowMSizeOptimization
This commit is contained in:
parent
579bdaddb9
commit
a0a0a34a21
@ -19,6 +19,7 @@ Compiler Features:
|
|||||||
Bugfixes:
|
Bugfixes:
|
||||||
* View/Pure Checker: Properly detect state variable access through base class.
|
* View/Pure Checker: Properly detect state variable access through base class.
|
||||||
* Yul analyzer: Check availability of data objects already in analysis phase.
|
* Yul analyzer: Check availability of data objects already in analysis phase.
|
||||||
|
* Yul Optimizer: Fix an issue where memory-accessing code was removed even though ``msize`` was used in the program.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,15 +119,13 @@ void UnusedPruner::operator()(Block& _block)
|
|||||||
void UnusedPruner::runUntilStabilised(
|
void UnusedPruner::runUntilStabilised(
|
||||||
Dialect const& _dialect,
|
Dialect const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
bool _allowMSizeOptization,
|
bool _allowMSizeOptimization,
|
||||||
set<YulString> const& _externallyUsedFunctions
|
set<YulString> const& _externallyUsedFunctions
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_allowMSizeOptization = !SideEffectsCollector(_dialect, _ast).containsMSize();
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
UnusedPruner pruner(_dialect, _ast, _allowMSizeOptization, _externallyUsedFunctions);
|
UnusedPruner pruner(_dialect, _ast, _allowMSizeOptimization, _externallyUsedFunctions);
|
||||||
pruner(_ast);
|
pruner(_ast);
|
||||||
if (!pruner.shouldRunAgain())
|
if (!pruner.shouldRunAgain())
|
||||||
return;
|
return;
|
||||||
|
@ -34,6 +34,11 @@ struct Dialect;
|
|||||||
* Optimisation stage that removes unused variables and functions and also
|
* Optimisation stage that removes unused variables and functions and also
|
||||||
* removes side-effect-free expression statements.
|
* removes side-effect-free expression statements.
|
||||||
*
|
*
|
||||||
|
* If msize is used, we cannot remove any statements that access memory.
|
||||||
|
* Because of that, the Unused Pruner should only be invoked on full ASTs,
|
||||||
|
* such that it can check for the presence of msize itself, or
|
||||||
|
* the `_allowMSizeOptimization` needs to be passed.
|
||||||
|
*
|
||||||
* Note that this does not remove circular references.
|
* Note that this does not remove circular references.
|
||||||
*
|
*
|
||||||
* Prerequisite: Disambiguator
|
* Prerequisite: Disambiguator
|
||||||
@ -64,7 +69,7 @@ public:
|
|||||||
static void runUntilStabilised(
|
static void runUntilStabilised(
|
||||||
Dialect const& _dialect,
|
Dialect const& _dialect,
|
||||||
Block& _ast,
|
Block& _ast,
|
||||||
bool _allowMSizeOptization,
|
bool _allowMSizeOptimization,
|
||||||
std::set<YulString> const& _externallyUsedFunctions = {}
|
std::set<YulString> const& _externallyUsedFunctions = {}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
{
|
||||||
|
let _13_71 := 1
|
||||||
|
let _17_72 := pc()
|
||||||
|
let _22_75 := pc()
|
||||||
|
let _25_76 := pc()
|
||||||
|
let _30_80 := pc()
|
||||||
|
let _32_81 := pc()
|
||||||
|
// This should not be removed
|
||||||
|
pop(keccak256(1, 2))
|
||||||
|
let _104 := gt(not(_17_72), _13_71)
|
||||||
|
let _105 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
mstore(lt(or(gt(_13_71, or(or(gt(or(or(or(gt(or(gt(_105, _32_81), _13_71), _30_80), lt(or(_13_71, add(_25_76, _105)), _13_71)), _22_75), _13_71), _13_71), _104), _13_71)), _13_71), _13_71), _13_71)
|
||||||
|
foo_singlereturn_1()
|
||||||
|
}
|
||||||
|
function foo_singlereturn_1()
|
||||||
|
{
|
||||||
|
extcodecopy(1, msize(), 1, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// step: stackCompressor
|
||||||
|
// ----
|
||||||
|
// {
|
||||||
|
// let _17_72 := pc()
|
||||||
|
// let _22_75 := pc()
|
||||||
|
// let _25_76 := pc()
|
||||||
|
// let _30_80 := pc()
|
||||||
|
// let _32_81 := pc()
|
||||||
|
// pop(keccak256(1, 2))
|
||||||
|
// let _105 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
|
// mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(_105, _32_81), 1), _30_80), lt(or(1, add(_25_76, _105)), 1)), _22_75), 1), 1), gt(not(_17_72), 1)), 1)), 1), 1), 1)
|
||||||
|
// foo_singlereturn_1()
|
||||||
|
// function foo_singlereturn_1()
|
||||||
|
// { extcodecopy(1, msize(), 1, 1) }
|
||||||
|
// }
|
Loading…
Reference in New Issue
Block a user