Merge pull request #11717 from jaa2/develop

Handle --optimize-runs option in assembly mode
This commit is contained in:
Harikrishnan Mulackal
2021-07-29 18:56:22 +02:00
committed by GitHub
12 changed files with 88 additions and 5 deletions
+1
View File
@@ -0,0 +1 @@
--yul --yul-dialect evm --optimize --ir-optimized --optimize-runs 10000
+1
View File
@@ -0,0 +1 @@
Warning: Yul is still experimental. Please use the output with care.
@@ -0,0 +1,13 @@
object "RunsTest1" {
code {
// Deploy the contract
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
code {
let funcSel := shl(224, 0xabc12345)
mstore(0, funcSel)
}
}
}
@@ -0,0 +1,52 @@
======= yul_optimize_runs/input.yul (EVM) =======
Pretty printed source:
object "RunsTest1" {
code {
{
let _1 := datasize("Runtime")
datacopy(0, dataoffset("Runtime"), _1)
return(0, _1)
}
}
object "Runtime" {
code {
{
mstore(0, 0xabc1234500000000000000000000000000000000000000000000000000000000)
}
}
}
}
Binary representation:
602480600d600039806000f3fe7fabc1234500000000000000000000000000000000000000000000000000000000600052
Text representation:
/* "yul_optimize_runs/input.yul":106:125 */
dataSize(sub_0)
dup1
/* "yul_optimize_runs/input.yul":83:104 */
dataOffset(sub_0)
/* "yul_optimize_runs/input.yul":80:81 */
0x00
/* "yul_optimize_runs/input.yul":71:126 */
codecopy
/* "yul_optimize_runs/input.yul":145:164 */
dup1
/* "yul_optimize_runs/input.yul":80:81 */
0x00
/* "yul_optimize_runs/input.yul":135:165 */
return
stop
sub_0: assembly {
/* "yul_optimize_runs/input.yul":237:257 */
0xabc1234500000000000000000000000000000000000000000000000000000000
/* "yul_optimize_runs/input.yul":277:278 */
0x00
/* "yul_optimize_runs/input.yul":270:288 */
mstore
}
+4 -1
View File
@@ -294,7 +294,7 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options)
if (expectedLanguage == AssemblyStack::Language::StrictAssembly || expectedLanguage == AssemblyStack::Language::Ewasm)
commandLine += vector<string>{
"--optimize",
"--optimize-runs=1000", // Ignored in assembly mode
"--optimize-runs=1000",
"--yul-optimizations=agf",
};
@@ -332,7 +332,10 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options)
{
expectedOptions.optimizer.enabled = true;
expectedOptions.optimizer.yulSteps = "agf";
expectedOptions.optimizer.expectedExecutionsPerDeployment = 1000;
}
else
expectedOptions.optimizer.expectedExecutionsPerDeployment = OptimiserSettings{}.expectedExecutionsPerDeployment;
stringstream sout, serr;
optional<CommandLineOptions> parsedOptions = parseCommandLine(commandLine, sout, serr);