Added more tests. Updated chromosome. Remove unused headers.

This commit is contained in:
hrkrshnn 2022-01-03 15:19:25 +05:30
parent b354c81a63
commit 85d1a57e65
10 changed files with 172 additions and 10 deletions

View File

@ -25,16 +25,9 @@
#include <libyul/optimiser/CallGraphGenerator.h>
#include <libyul/optimiser/OptimizerUtilities.h>
#include <libyul/optimiser/Semantics.h>
#include <libyul/optimiser/CallGraphGenerator.h>
#include <libyul/SideEffects.h>
#include <libyul/AST.h>
#include <libyul/Utilities.h>
#include <libevmasm/GasMeter.h>
#include <libsolutil/Keccak256.h>
#include <limits>
using namespace std;
using namespace solidity;
using namespace solidity::util;

View File

@ -23,7 +23,6 @@
#include <libyul/optimiser/Semantics.h>
#include <libyul/optimiser/OptimiserStep.h>
#include <libyul/optimiser/OptimizerUtilities.h>
#include <libyul/AST.h>
#include <libsolutil/CommonData.h>

View File

@ -178,7 +178,7 @@ contract DepositContract is IDepositContract, ERC165 {
// compileViaYul: also
// ----
// constructor()
// gas irOptimized: 1558001
// gas irOptimized: 1557137
// gas legacy: 2436584
// gas legacyOptimized: 1776483
// supportsInterface(bytes4): 0x0 -> 0

View File

@ -0,0 +1,25 @@
{
let a := calldataload(0)
let b := 20
sstore(a, b)
if calldataload(32) {
sstore(a, b)
pop(staticcall(0, 0, 0, 0, 0, 0))
sstore(a, b)
}
sstore(a, b)
}
// ====
// EVMVersion: >=byzantium
// ----
// step: equalStoreEliminator
//
// {
// let a := calldataload(0)
// let b := 20
// sstore(a, b)
// if calldataload(32)
// {
// pop(staticcall(0, 0, 0, 0, 0, 0))
// }
// }

View File

@ -0,0 +1,20 @@
{
let x := calldataload(0)
let y := calldataload(1)
sstore(x, y)
for {let a := 1} lt(a, 10) {a := add(a, 1) } {
sstore(x, y)
}
}
// ----
// step: equalStoreEliminator
//
// {
// let x := calldataload(0)
// let y := calldataload(1)
// sstore(x, y)
// let a := 1
// for { } lt(a, 10) { a := add(a, 1) }
// { sstore(x, y) }
// }

View File

@ -0,0 +1,56 @@
{
f(calldataload(0), calldataload(32))
h(calldataload(64), calldataload(96))
function f(a, b) {
// gets removed
sstore(a, b)
g()
sstore(a, b)
}
function g() {
pop(staticcall(0, 0, 0, 0, 0, 0))
}
function h(a_, b_) {
// cannot be removed
sstore(a_, b_)
i()
sstore(a_, b_)
}
function i() {
pop(delegatecall(0, 0, 0, 0, 0, 0))
}
}
// ====
// EVMVersion: >=byzantium
// ----
// step: equalStoreEliminator
//
// {
// f(calldataload(0), calldataload(32))
// h(calldataload(64), calldataload(96))
// function f(a, b)
// {
// sstore(a, b)
// g()
// }
// function g()
// {
// pop(staticcall(0, 0, 0, 0, 0, 0))
// }
// function h(a_, b_)
// {
// sstore(a_, b_)
// i()
// sstore(a_, b_)
// }
// function i()
// {
// pop(delegatecall(0, 0, 0, 0, 0, 0))
// }
// }

View File

@ -0,0 +1,24 @@
{
let x := calldataload(0)
let y := sload(x)
// both of these can be removed
sstore(x, y)
sstore(x, y)
let a := x
let b := mload(a)
// both of these can be removed
mstore(a, b)
mstore(a, b)
}
// ====
// EVMVersion: >=byzantium
// ----
// step: equalStoreEliminator
//
// {
// let x := calldataload(0)
// let y := sload(x)
// let a := x
// let b := mload(a)
// }

View File

@ -0,0 +1,18 @@
{
let x := calldataload(0)
let y := calldataload(32)
sstore(x, y)
y := calldataload(64)
// cannot be removed
sstore(x, y)
}
// ----
// step: equalStoreEliminator
//
// {
// let x := calldataload(0)
// let y := calldataload(32)
// sstore(x, y)
// y := calldataload(64)
// sstore(x, y)
// }

View File

@ -0,0 +1,27 @@
{
let a := calldataload(0)
let b := 20
sstore(a, b)
if calldataload(32) {
sstore(a, b)
pop(staticcall(0, 0, 0, 0, 0, 0))
verbatim_0i_0o("xyz")
}
sstore(a, b)
}
// ====
// EVMVersion: >=byzantium
// ----
// step: equalStoreEliminator
//
// {
// let a := calldataload(0)
// let b := 20
// sstore(a, b)
// if calldataload(32)
// {
// pop(staticcall(0, 0, 0, 0, 0, 0))
// verbatim_0i_0o("xyz")
// }
// sstore(a, b)
// }

View File

@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(output_operator_should_create_concise_and_unambiguous_strin
BOOST_TEST(chromosome.length() == allSteps.size());
BOOST_TEST(chromosome.optimisationSteps() == allSteps);
BOOST_TEST(toString(chromosome) == "flcCUnDEvejsxIOoighFTLMRrmVatpud");
BOOST_TEST(toString(chromosome) == "flcCUnDEvejsxIOoighFTLMRmVatrpud");
}
BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names)