Merge pull request #14511 from ethereum/semantic-tests-via-ir

Semantic tests via IR
This commit is contained in:
Daniel 2023-08-23 16:42:03 +02:00 committed by GitHub
commit 78b1f5acc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 222 additions and 124 deletions

View File

@ -45,6 +45,17 @@ using namespace boost::algorithm;
using namespace boost::unit_test;
namespace fs = boost::filesystem;
ostream& solidity::frontend::test::operator<<(ostream& _output, RequiresYulOptimizer _requiresYulOptimizer)
{
switch (_requiresYulOptimizer)
{
case RequiresYulOptimizer::False: _output << "false"; break;
case RequiresYulOptimizer::MinimalStack: _output << "minimalStack"; break;
case RequiresYulOptimizer::Full: _output << "full"; break;
}
return _output;
}
SemanticTest::SemanticTest(
string const& _filename,
langutil::EVMVersion _evmVersion,
@ -66,6 +77,16 @@ SemanticTest::SemanticTest(
static set<string> const yulRunTriggers{"also", "true"};
static set<string> const legacyRunTriggers{"also", "false", "default"};
m_requiresYulOptimizer = m_reader.enumSetting<RequiresYulOptimizer>(
"requiresYulOptimizer",
{
{toString(RequiresYulOptimizer::False), RequiresYulOptimizer::False},
{toString(RequiresYulOptimizer::MinimalStack), RequiresYulOptimizer::MinimalStack},
{toString(RequiresYulOptimizer::Full), RequiresYulOptimizer::Full},
},
toString(RequiresYulOptimizer::False)
);
m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false);
if (m_runWithABIEncoderV1Only && !solidity::test::CommonOptions::get().useABIEncoderV1)
m_shouldRun = false;
@ -272,15 +293,39 @@ optional<AnnotatedEventSignature> SemanticTest::matchEvent(util::h256 const& has
return result;
}
frontend::OptimiserSettings SemanticTest::optimizerSettingsFor(RequiresYulOptimizer _requiresYulOptimizer)
{
switch (_requiresYulOptimizer)
{
case RequiresYulOptimizer::False:
return OptimiserSettings::minimal();
case RequiresYulOptimizer::MinimalStack:
{
OptimiserSettings settings = OptimiserSettings::minimal();
settings.runYulOptimiser = true;
settings.yulOptimiserSteps = "uljmul jmul";
return settings;
}
case RequiresYulOptimizer::Full:
return OptimiserSettings::full();
}
unreachable();
}
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
TestResult result = TestResult::Success;
if (m_testCaseWantsLegacyRun && !m_eofVersion.has_value())
result = runTest(_stream, _linePrefix, _formatted, false);
result = runTest(_stream, _linePrefix, _formatted, false /* _isYulRun */);
if (m_testCaseWantsYulRun && result == TestResult::Success)
result = runTest(_stream, _linePrefix, _formatted, true);
{
if (solidity::test::CommonOptions::get().optimize)
result = runTest(_stream, _linePrefix, _formatted, true /* _isYulRun */);
else
result = tryRunTestWithYulOptimizer(_stream, _linePrefix, _formatted);
}
if (result != TestResult::Success)
solidity::test::CommonOptions::get().printSelectedOptions(
@ -296,7 +341,8 @@ TestCase::TestResult SemanticTest::runTest(
ostream& _stream,
string const& _linePrefix,
bool _formatted,
bool _isYulRun)
bool _isYulRun
)
{
bool success = true;
m_gasCostFailure = false;
@ -470,6 +516,53 @@ TestCase::TestResult SemanticTest::runTest(
return TestResult::Success;
}
TestCase::TestResult SemanticTest::tryRunTestWithYulOptimizer(
std::ostream& _stream,
std::string const& _linePrefix,
bool _formatted
)
{
TestResult result{};
for (auto requiresYulOptimizer: {
RequiresYulOptimizer::False,
RequiresYulOptimizer::MinimalStack,
RequiresYulOptimizer::Full,
})
{
ScopedSaveAndRestore optimizerSettings(
m_optimiserSettings,
optimizerSettingsFor(requiresYulOptimizer)
);
try
{
result = runTest(_stream, _linePrefix, _formatted, true /* _isYulRun */);
}
catch (yul::StackTooDeepError const&)
{
if (requiresYulOptimizer == RequiresYulOptimizer::Full)
throw;
else
continue;
}
if (m_requiresYulOptimizer != requiresYulOptimizer && result != TestResult::FatalError)
{
soltestAssert(result == TestResult::Success || result == TestResult::Failure);
AnsiColorized(_stream, _formatted, {BOLD, YELLOW})
<< _linePrefix << endl
<< _linePrefix << "requiresYulOptimizer is set to " << m_requiresYulOptimizer
<< " but should be " << requiresYulOptimizer << endl;
m_requiresYulOptimizer = requiresYulOptimizer;
return TestResult::Failure;
}
return result;
}
unreachable();
}
bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const
{
string setting =
@ -576,12 +669,16 @@ void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) con
void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix)
{
auto& settings = m_reader.settings();
if (settings.empty())
if (settings.empty() && m_requiresYulOptimizer == RequiresYulOptimizer::False)
return;
_stream << _linePrefix << "// ====" << endl;
if (m_requiresYulOptimizer != RequiresYulOptimizer::False)
_stream << _linePrefix << "// requiresYulOptimizer: " << m_requiresYulOptimizer << endl;
for (auto const& [settingName, settingValue]: settings)
_stream << _linePrefix << "// " << settingName << ": " << settingValue<< endl;
if (settingName != "requiresYulOptimizer")
_stream << _linePrefix << "// " << settingName << ": " << settingValue<< endl;
}
void SemanticTest::parseExpectations(istream& _stream)

View File

@ -37,6 +37,15 @@ struct AnnotatedEventSignature
std::vector<std::string> nonIndexedTypes;
};
enum class RequiresYulOptimizer
{
False,
MinimalStack,
Full,
};
std::ostream& operator<<(std::ostream& _output, RequiresYulOptimizer _requiresYulOptimizer);
/**
* Class that represents a semantic test (or end-to-end test) and allows running it as part of the
* boost unit test environment or isoltest. It reads the Solidity source and an additional comment
@ -83,13 +92,26 @@ public:
bool deploy(std::string const& _contractName, u256 const& _value, bytes const& _arguments, std::map<std::string, solidity::test::Address> const& _libraries = {});
private:
TestResult runTest(std::ostream& _stream, std::string const& _linePrefix, bool _formatted, bool _isYulRun);
TestResult runTest(
std::ostream& _stream,
std::string const& _linePrefix,
bool _formatted,
bool _isYulRun
);
TestResult tryRunTestWithYulOptimizer(
std::ostream& _stream,
std::string const& _linePrefix,
bool _formatted
);
bool checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const;
std::map<std::string, Builtin> makeBuiltins();
std::vector<SideEffectHook> makeSideEffectHooks() const;
std::vector<std::string> eventSideEffectHook(FunctionCall const&) const;
std::optional<AnnotatedEventSignature> matchEvent(util::h256 const& hash) const;
static std::string formatEventParameter(std::optional<AnnotatedEventSignature> _signature, bool _indexed, size_t _index, bytes const& _data);
OptimiserSettings optimizerSettingsFor(RequiresYulOptimizer _requiresYulOptimizer);
SourceMap m_sources;
std::size_t m_lineOffset;
std::vector<TestFunctionCall> m_tests;
@ -101,6 +123,7 @@ private:
bool m_allowNonExistingFunctions = false;
bool m_gasCostFailure = false;
bool m_enforceGasCost = false;
RequiresYulOptimizer m_requiresYulOptimizer{};
u256 m_enforceGasCostMinValue;
};

View File

@ -35,6 +35,8 @@
#include <libsolutil/Keccak256.h>
#include <libsolutil/ErrorCodes.h>
#include <libyul/Exceptions.h>
#include <boost/test/unit_test.hpp>
#include <range/v3/view/transform.hpp>
@ -51,16 +53,32 @@ using namespace solidity::util;
using namespace solidity::test;
using namespace solidity::langutil;
#define ALSO_VIA_YUL(CODE) \
{ \
m_compileViaYul = false; \
{ CODE } \
\
m_compileViaYul = true; \
reset(); \
{ CODE } \
#define ALSO_VIA_YUL(CODE) \
{ \
m_compileViaYul = false; \
RUN_AND_RERUN_WITH_OPTIMIZER_ON_STACK_ERROR(CODE) \
\
m_compileViaYul = true; \
reset(); \
RUN_AND_RERUN_WITH_OPTIMIZER_ON_STACK_ERROR(CODE) \
}
#define RUN_AND_RERUN_WITH_OPTIMIZER_ON_STACK_ERROR(CODE) \
{ \
try \
{ CODE } \
catch (yul::StackTooDeepError const&) \
{ \
if (m_optimiserSettings == OptimiserSettings::full()) \
throw; \
\
reset(); \
m_optimiserSettings = OptimiserSettings::full(); \
{ CODE } \
} \
}
namespace solidity::frontend::test
{

View File

@ -25,6 +25,7 @@
#include <test/libsolidity/util/Common.h>
#include <liblangutil/DebugInfoSelection.h>
#include <libyul/Exceptions.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
@ -60,13 +61,14 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
m_compiler.setEVMVersion(m_evmVersion);
m_compiler.setEOFVersion(m_eofVersion);
m_compiler.setOptimiserSettings(m_optimiserSettings);
m_compiler.enableEvmBytecodeGeneration(!m_compileViaYul);
m_compiler.enableIRGeneration(m_compileViaYul);
m_compiler.enableEvmBytecodeGeneration(true);
m_compiler.setViaIR(m_compileViaYul);
m_compiler.setRevertStringBehaviour(m_revertStrings);
if (!m_appendCBORMetadata) {
m_compiler.setMetadataFormat(CompilerStack::MetadataFormat::NoMetadata);
}
m_compiler.setMetadataHash(m_metadataHash);
if (!m_compiler.compile())
{
// The testing framework expects an exception for
@ -80,49 +82,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
BOOST_ERROR("Compiling contract failed");
}
string contractName(_contractName.empty() ? m_compiler.lastContractName(_mainSourceName) : _contractName);
evmasm::LinkerObject obj;
if (m_compileViaYul)
{
// Try compiling twice: If the first run fails due to stack errors, forcefully enable
// the optimizer.
for (bool forceEnableOptimizer: {false, true})
{
OptimiserSettings optimiserSettings = m_optimiserSettings;
if (!forceEnableOptimizer && !optimiserSettings.runYulOptimiser)
{
// Enable some optimizations on the first run
optimiserSettings.runYulOptimiser = true;
optimiserSettings.yulOptimiserSteps = "uljmul jmul";
}
else if (forceEnableOptimizer)
optimiserSettings = OptimiserSettings::full();
yul::YulStack asmStack(
m_evmVersion,
m_eofVersion,
yul::YulStack::Language::StrictAssembly,
optimiserSettings,
DebugInfoSelection::All()
);
bool analysisSuccessful = asmStack.parseAndAnalyze("", m_compiler.yulIROptimized(contractName));
solAssert(analysisSuccessful, "Code that passed analysis in CompilerStack can't have errors");
try
{
asmStack.optimize();
obj = std::move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode);
obj.link(_libraryAddresses);
break;
}
catch (...)
{
if (forceEnableOptimizer || optimiserSettings == OptimiserSettings::full())
throw;
}
}
}
else
obj = m_compiler.object(contractName);
evmasm::LinkerObject obj = m_compiler.object(contractName);
BOOST_REQUIRE(obj.linkReferences.empty());
if (m_showMetadata)
cout << "metadata: " << m_compiler.metadata(contractName) << endl;

View File

@ -30,6 +30,6 @@ contract C is B {
}
// ----
// test() -> 77
// gas irOptimized: 110731
// gas irOptimized: 110325
// gas legacy: 151866
// gas legacyOptimized: 110359

View File

@ -33,7 +33,7 @@ contract C {
// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5, 6 -> 0x20, 0x40, 5, 2
// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1 -> FAILURE
// f_storage(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0x60, 0x20, 1, 2
// gas irOptimized: 111639
// gas irOptimized: 111642
// gas legacy: 112944
// gas legacyOptimized: 112092
// f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0x80, 0x20, 2, 5, 6

View File

@ -16,11 +16,11 @@ contract C {
// test_boundary_check(uint256,uint256): 1, 1 -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 10, 10 -> FAILURE, hex"4e487b71", 0x32
// test_boundary_check(uint256,uint256): 256, 256 -> FAILURE, hex"4e487b71", 0x32
// gas irOptimized: 137904
// gas irOptimized: 137913
// gas legacy: 133633
// gas legacyOptimized: 114354
// test_boundary_check(uint256,uint256): 256, 255 -> 0
// gas irOptimized: 140039
// gas irOptimized: 140048
// gas legacy: 135949
// gas legacyOptimized: 116533
// test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32

View File

@ -17,6 +17,6 @@ contract c {
}
// ----
// test() -> 0
// gas irOptimized: 125212
// gas irOptimized: 125058
// gas legacy: 150372
// gas legacyOptimized: 146391

View File

@ -18,6 +18,6 @@ contract c {
}
// ----
// test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000
// gas irOptimized: 208044
// gas irOptimized: 208053
// gas legacy: 221769
// gas legacyOptimized: 220611

View File

@ -12,6 +12,6 @@ contract c {
}
// ----
// test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10
// gas irOptimized: 689666
// gas irOptimized: 689654
// gas legacy: 686178
// gas legacyOptimized: 685628

View File

@ -15,6 +15,6 @@ contract C {
}
// ----
// f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3
// gas irOptimized: 161627
// gas irOptimized: 161624
// gas legacy: 162203
// gas legacyOptimized: 159934

View File

@ -38,7 +38,7 @@ contract Test {
}
// ----
// test() -> 24
// gas irOptimized: 226661
// gas irOptimized: 226666
// gas legacy: 227084
// gas legacyOptimized: 226529
// test1() -> 3

View File

@ -26,4 +26,4 @@ contract C {
// compileViaYul: true
// ----
// f() -> 3, 3, 3, 1
// gas irOptimized: 181912
// gas irOptimized: 181894

View File

@ -37,7 +37,7 @@ contract C {
}
// ----
// from_storage() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14
// gas irOptimized: 147868
// gas irOptimized: 147871
// gas legacy: 148896
// gas legacyOptimized: 146901
// from_storage_ptr() -> 0x20, 2, 0x40, 0xa0, 2, 10, 11, 3, 12, 13, 14

View File

@ -17,25 +17,25 @@ contract c {
// ----
// f(uint256): 0 -> 0x20, 0x00
// f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00
// gas irOptimized: 109794
// gas irOptimized: 109839
// gas legacy: 123948
// gas legacyOptimized: 118948
// f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671
// gas irOptimized: 124047
// gas irOptimized: 124049
// gas legacy: 140362
// gas legacyOptimized: 135386
// f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 130663
// gas irOptimized: 130665
// gas legacy: 147916
// gas legacyOptimized: 142278
// f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992
// gas irOptimized: 139543
// gas irOptimized: 139545
// gas legacy: 171136
// gas legacyOptimized: 161538
// f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000
// gas legacy: 59345
// gas legacyOptimized: 57279
// f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968
// gas irOptimized: 442419
// gas irOptimized: 442421
// gas legacy: 505021
// gas legacyOptimized: 486997

View File

@ -35,11 +35,11 @@ contract C {
}
// ----
// f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000
// gas irOptimized: 179737
// gas irOptimized: 179734
// gas legacy: 181001
// gas legacyOptimized: 180018
// g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000
// gas irOptimized: 106666
// gas irOptimized: 106663
// gas legacy: 109720
// gas legacyOptimized: 106932
// h() -> 0x40, 0x60, 0x00, 0x00

View File

@ -15,6 +15,6 @@ contract C {
}
// ----
// test() -> 7
// gas irOptimized: 122454
// gas irOptimized: 122456
// gas legacy: 205176
// gas legacyOptimized: 204971

View File

@ -31,8 +31,8 @@ contract C {
// compileViaYul: true
// ----
// test1((uint8[],uint8[2])[][][]): 0x20, 1, 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29
// gas irOptimized: 327844
// gas irOptimized: 327847
// test2((uint8[],uint8[2])[][1][]): 0x20, 2, 0x40, 0x0160, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13, 0x20, 1, 0x20, 0x60, 31, 37, 2, 23, 29 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 140870
// test3((uint8[],uint8[2])[1][][2]): 0x20, 0x40, 0x60, 0, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 188515
// gas irOptimized: 188517

View File

@ -31,8 +31,8 @@ contract C {
// compileViaYul: true
// ----
// test1((uint8[],uint8[2])[][][]): 0x20, 1, 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29
// gas irOptimized: 332687
// gas irOptimized: 332666
// test2((uint8[],uint8[2])[][1][]): 0x20, 2, 0x40, 0x0160, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13, 0x20, 1, 0x20, 0x60, 31, 37, 2, 23, 29 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 145161
// gas irOptimized: 145152
// test3((uint8[],uint8[2])[1][][2]): 0x20, 0x40, 0x60, 0, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 288, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 192608
// gas irOptimized: 192602

View File

@ -46,11 +46,11 @@ contract C {
}
// ----
// test() -> 0x20, 0x14, "[a called][b called]"
// gas irOptimized: 116631
// gas irOptimized: 116633
// gas legacy: 118936
// gas legacyOptimized: 116975
// test2() -> 0x20, 0x14, "[b called][a called]"
// test3() -> 0x20, 0x14, "[b called][a called]"
// gas irOptimized: 103241
// gas irOptimized: 103243
// gas legacy: 102745
// gas legacyOptimized: 101669

View File

@ -18,6 +18,6 @@ contract C {
}
// ----
// f() -> 3
// gas irOptimized: 128273
// gas irOptimized: 128264
// gas legacy: 130584
// gas legacyOptimized: 129028

View File

@ -29,8 +29,8 @@ contract C {
// compileViaYul: true
// ----
// test1((uint8[],uint8[2])[][]): 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29
// gas irOptimized: 304751
// gas irOptimized: 304720
// test2((uint8[],uint8[2])[][1]): 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 116449
// gas irOptimized: 116455
// test3((uint8[],uint8[2])[1][]): 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 188004
// gas irOptimized: 188006

View File

@ -29,8 +29,8 @@ contract C {
// compileViaYul: true
// ----
// test1((uint8[],uint8[2])[][]): 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29 -> 0x20, 2, 0x40, 0x0140, 1, 0x20, 0x60, 3, 7, 2, 1, 2, 2, 0x40, 0x0100, 0x60, 17, 19, 2, 11, 13, 0x60, 31, 37, 2, 23, 29
// gas irOptimized: 309071
// gas irOptimized: 309077
// test2((uint8[],uint8[2])[][1]): 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 0x20, 1, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 118264
// gas irOptimized: 118258
// test3((uint8[],uint8[2])[1][]): 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13 -> 0x20, 2, 0x40, 0x0120, 0x20, 0x60, 3, 7, 2, 1, 2, 0x20, 0x60, 17, 19, 2, 11, 13
// gas irOptimized: 191003
// gas irOptimized: 190997

View File

@ -65,5 +65,5 @@ contract C {
// test1()
// gas irOptimized: 123202
// test2()
// gas irOptimized: 123030
// gas irOptimized: 123027
// test3()

View File

@ -11,6 +11,6 @@ contract C {
}
// ----
// f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000
// gas irOptimized: 202738
// gas irOptimized: 202735
// gas legacy: 204798
// gas legacyOptimized: 203357

View File

@ -16,6 +16,6 @@ contract c {
}
// ----
// test1() -> true
// gas irOptimized: 206086
// gas irOptimized: 206386
// gas legacy: 254056
// gas legacyOptimized: 246892

View File

@ -42,6 +42,6 @@ contract C {
}
// ----
// test() -> 5, 6, 7
// gas irOptimized: 256074
// gas irOptimized: 256077
// gas legacy: 441556
// gas legacyOptimized: 279321

View File

@ -18,7 +18,7 @@ contract c {
}
// ----
// test() -> 38, 28, 18
// gas irOptimized: 148087
// gas irOptimized: 148543
// gas legacy: 151184
// gas legacyOptimized: 142418
// storageEmpty -> 1

View File

@ -16,7 +16,7 @@ contract c {
}
// ----
// test() -> true
// gas irOptimized: 140056
// gas irOptimized: 140154
// gas legacy: 178397
// gas legacyOptimized: 163832
// storageEmpty -> 1

View File

@ -9,6 +9,6 @@ contract c {
}
// ----
// test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000
// gas irOptimized: 107969
// gas irOptimized: 107976
// gas legacy: 125420
// gas legacyOptimized: 122472

View File

@ -15,6 +15,6 @@ contract c {
}
// ----
// test() -> 0
// gas irOptimized: 172113
// gas irOptimized: 171996
// gas legacy: 215891
// gas legacyOptimized: 203615

View File

@ -21,7 +21,7 @@ contract C {
// ----
// l() -> 0
// g(uint256): 70 ->
// gas irOptimized: 182497
// gas irOptimized: 182707
// gas legacy: 183445
// gas legacyOptimized: 178995
// l() -> 70

View File

@ -28,7 +28,7 @@ contract C {
// compileViaYul: also
// ----
// constructor() ->
// gas irOptimized: 439080
// gas irOptimized: 442530
// gas legacy: 711299
// gas legacyOptimized: 481296
// h() -> 0x20, 0x40, 0x00, 0

View File

@ -24,6 +24,6 @@ contract Creator {
}
// ----
// f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8
// gas irOptimized: 424511
// gas irOptimized: 424508
// gas legacy: 581443
// gas legacyOptimized: 444588

View File

@ -24,6 +24,6 @@ contract Creator {
}
// ----
// f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h"
// gas irOptimized: 275287
// gas irOptimized: 275487
// gas legacy: 418462
// gas legacyOptimized: 291760

View File

@ -9,7 +9,7 @@ contract C {
}
// ----
// constructor(): 1, 2, 3, 4 ->
// gas irOptimized: 171018
// gas irOptimized: 170999
// gas legacy: 218378
// gas legacyOptimized: 176195
// a() -> 1

View File

@ -48,7 +48,7 @@ contract test {
}
// ----
// constructor()
// gas irOptimized: 1723462
// gas irOptimized: 1723666
// gas legacy: 2210160
// gas legacyOptimized: 1734152
// div(uint256,uint256): 3141592653589793238, 88714123 -> 35412542528203691288251815328

View File

@ -33,7 +33,7 @@ contract test {
}
// ----
// constructor()
// gas irOptimized: 406643
// gas irOptimized: 407075
// gas legacy: 631753
// gas legacyOptimized: 459425
// prb_pi() -> 3141592656369545286

View File

@ -49,7 +49,7 @@ contract test {
}
// ----
// constructor()
// gas irOptimized: 632372
// gas irOptimized: 633020
// gas legacy: 1065857
// gas legacyOptimized: 725207
// toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0
@ -69,6 +69,6 @@ contract test {
// gas legacy: 31621
// gas legacyOptimized: 27914
// benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020
// gas irOptimized: 1981664
// gas irOptimized: 1981677
// gas legacy: 4235651
// gas legacyOptimized: 2319622

View File

@ -3,9 +3,9 @@ contract C {
function f(uint x, uint y) external payable returns (uint) { return 2; }
function call() public payable returns (uint v, uint x, uint y, uint z) {
v = this.f{value: 10}(2);
x = this.f{gas: 1000}(2, 3);
y = this.f{gas: 1000, value: 10}(2, 3);
z = this.f{value: 10, gas: 1000}(2, 3);
x = this.f{gas: 10000}(2, 3);
y = this.f{gas: 10000, value: 10}(2, 3);
z = this.f{value: 10, gas: 10000}(2, 3);
}
function bal() external returns (uint) { return address(this).balance; }
receive() external payable {}

View File

@ -27,7 +27,7 @@ contract C {
}
// ----
// f() -> 3, 7, 5
// gas irOptimized: 124003
// gas irOptimized: 124024
// gas legacy: 148528
// gas legacyOptimized: 123971
// x() -> 7

View File

@ -22,6 +22,6 @@ contract Test {
// ----
// library: Lib
// f() -> 4, 0x11
// gas irOptimized: 112115
// gas irOptimized: 112046
// gas legacy: 135413
// gas legacyOptimized: 119325

View File

@ -22,7 +22,7 @@ contract Test {
// set(bytes): 0x20, 0
// storageEmpty -> 1
// set(bytes): 0x20, 66, "12345678901234567890123456789012", "12345678901234567890123456789012", "12"
// gas irOptimized: 111878
// gas irOptimized: 111886
// gas legacy: 112734
// gas legacyOptimized: 112115
// storageEmpty -> 0

View File

@ -44,7 +44,7 @@ contract C {
}
// ----
// to_state() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 121584
// gas irOptimized: 121598
// gas legacy: 123208
// gas legacyOptimized: 121766
// to_storage() -> 0x20, 0x60, 0xa0, 7, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14

View File

@ -52,14 +52,14 @@ contract C {
}
// ----
// from_memory() -> 0x20, 0x60, 0xa0, 0x15, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 123028
// gas irOptimized: 123034
// gas legacy: 130227
// gas legacyOptimized: 128761
// from_state() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 121703
// gas irOptimized: 121709
// gas legacy: 123282
// gas legacyOptimized: 121871
// from_calldata((bytes,uint16[],uint16)): 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -> 0x20, 0x60, 0xa0, 0x15, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 115113
// gas irOptimized: 115131
// gas legacy: 122516
// gas legacyOptimized: 120807

View File

@ -45,18 +45,18 @@ contract C {
}
// ----
// from_state() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 121680
// gas irOptimized: 121686
// gas legacy: 123144
// gas legacyOptimized: 121811
// from_storage() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 121725
// gas irOptimized: 121731
// gas legacy: 123193
// gas legacyOptimized: 121863
// from_memory() -> 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 122939
// gas irOptimized: 122942
// gas legacy: 130088
// gas legacyOptimized: 128757
// from_calldata((bytes,uint16[],uint16)): 0x20, 0x60, 0xa0, 21, 3, 0x666F6F0000000000000000000000000000000000000000000000000000000000, 2, 13, 14 -> 0x20, 0x60, 0xa0, 21, 3, 0x666f6f0000000000000000000000000000000000000000000000000000000000, 2, 13, 14
// gas irOptimized: 115032
// gas irOptimized: 115046
// gas legacy: 118301
// gas legacyOptimized: 115435

View File

@ -33,6 +33,6 @@ contract C {
}
// ----
// f(bytes): 0x20, 0x5, "abcde" -> 0
// gas irOptimized: 241832
// gas irOptimized: 241841
// gas legacy: 243284
// gas legacyOptimized: 242420