From 6d51dfb617b5eb6efbd3e0a414d604ac27e58cb3 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Tue, 9 Mar 2021 21:26:36 +0100 Subject: [PATCH 01/13] [isoltest] Adding gas used as semantic tests expectation. --- test/libsolidity/SemanticTest.cpp | 32 +++- test/libsolidity/SemanticTest.h | 3 + test/libsolidity/util/SoltestTypes.h | 74 +++++----- test/libsolidity/util/TestFileParser.cpp | 139 ++++++++++-------- test/libsolidity/util/TestFunctionCall.cpp | 14 +- test/libsolidity/util/TestFunctionCall.h | 6 + .../util/TestFunctionCallTests.cpp | 26 ++-- 7 files changed, 185 insertions(+), 109 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index d30908627..74bf508f7 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -133,6 +133,7 @@ TestCase::TestResult SemanticTest::runTest( ) { bool success = true; + m_gasCostFailure = false; if (_compileViaYul && _compileToEwasm) selectVM(evmc_capabilities::EVMC_CAPABILITY_EWASM); @@ -203,6 +204,8 @@ TestCase::TestResult SemanticTest::runTest( { if (m_transactionSuccessful == test.call().expectations.failure) success = false; + if (success && !checkGasCostExpectation(test, _compileViaYul)) + m_gasCostFailure = true; test.setFailure(!m_transactionSuccessful); test.setRawBytes(bytes()); @@ -239,6 +242,9 @@ TestCase::TestResult SemanticTest::runTest( } bool outputMismatch = (output != test.call().expectations.rawBytes()); + if (!outputMismatch && !checkGasCostExpectation(test, _compileViaYul)) + m_gasCostFailure = true; + // Pre byzantium, it was not possible to return failure data, so we disregard // output mismatch for those EVM versions. if (test.call().expectations.failure && !m_transactionSuccessful && !m_evmVersion.supportsReturndata()) @@ -297,9 +303,33 @@ TestCase::TestResult SemanticTest::runTest( return TestResult::Failure; } + if (m_gasCostFailure) + { + AnsiColorized(_stream, _formatted, {BOLD, CYAN}) + << _linePrefix << "Gas results missing or wrong, obtained result:" << endl; + for (auto const& test: m_tests) + { + ErrorReporter errorReporter; + _stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl; + _stream << errorReporter.format(_linePrefix, _formatted); + } + return TestResult::Failure; + } + return TestResult::Success; } +bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const +{ + string setting = + (_compileViaYul ? "ir"s : "legacy"s) + + (m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : ""); + io_test.setGasCost(setting, m_gasUsed); + return + io_test.call().expectations.gasUsed.count(setting) > 0 && + m_gasUsed == io_test.call().expectations.gasUsed.at(setting); +} + void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const { if (m_sources.sources.empty()) @@ -347,7 +377,7 @@ void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) const { for (TestFunctionCall const& test: m_tests) - _stream << test.format("", true, false) << endl; + _stream << test.format("", /* _renderResult = */ !m_gasCostFailure, /* _highlight = */ false) << endl; } void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix) diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index 6ba62c9f4..bb2960ab2 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -61,6 +61,7 @@ public: private: TestResult runTest(std::ostream& _stream, std::string const& _linePrefix, bool _formatted, bool _compileViaYul, bool _compileToEwasm); + bool checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const; SourceMap m_sources; std::size_t m_lineOffset; std::vector m_tests; @@ -72,6 +73,8 @@ private: bool m_allowNonExistingFunctions = false; bool m_compileViaYulCanBeSet = false; std::map m_builtins{}; + + bool m_gasCostFailure = false; }; } diff --git a/test/libsolidity/util/SoltestTypes.h b/test/libsolidity/util/SoltestTypes.h index fc8c1dfc1..a19378030 100644 --- a/test/libsolidity/util/SoltestTypes.h +++ b/test/libsolidity/util/SoltestTypes.h @@ -25,41 +25,42 @@ namespace solidity::frontend::test /** * All soltest tokens. */ -#define SOLT_TOKEN_LIST(T, K) \ - T(Unknown, "unknown", 0) \ - T(Invalid, "invalid", 0) \ - T(EOS, "EOS", 0) \ - T(Whitespace, "_", 0) \ - /* punctuations */ \ - T(LParen, "(", 0) \ - T(RParen, ")", 0) \ - T(LBrack, "[", 0) \ - T(RBrack, "]", 0) \ - T(LBrace, "{", 0) \ - T(RBrace, "}", 0) \ - T(Sub, "-", 0) \ - T(Colon, ":", 0) \ - T(Comma, ",", 0) \ - T(Period, ".", 0) \ - T(Arrow, "->", 0) \ - T(Newline, "//", 0) \ - /* Literals & identifier */ \ - T(Comment, "#", 0) \ - T(Number, "number", 0) \ - T(HexNumber, "hex_number", 0) \ - T(String, "string", 0) \ - T(Identifier, "identifier", 0) \ - /* type keywords */ \ - K(Ether, "ether", 0) \ - K(Wei, "wei", 0) \ - K(Hex, "hex", 0) \ - K(Boolean, "boolean", 0) \ - /* special keywords */ \ - K(Left, "left", 0) \ - K(Library, "library", 0) \ - K(Right, "right", 0) \ - K(Failure, "FAILURE", 0) \ - K(Storage, "storage", 0) \ +#define SOLT_TOKEN_LIST(T, K) \ + T(Unknown, "unknown", 0) \ + T(Invalid, "invalid", 0) \ + T(EOS, "EOS", 0) \ + T(Whitespace, "_", 0) \ + /* punctuations */ \ + T(LParen, "(", 0) \ + T(RParen, ")", 0) \ + T(LBrack, "[", 0) \ + T(RBrack, "]", 0) \ + T(LBrace, "{", 0) \ + T(RBrace, "}", 0) \ + T(Sub, "-", 0) \ + T(Colon, ":", 0) \ + T(Comma, ",", 0) \ + T(Period, ".", 0) \ + T(Arrow, "->", 0) \ + T(Newline, "//", 0) \ + /* Literals & identifier */ \ + T(Comment, "#", 0) \ + T(Number, "number", 0) \ + T(HexNumber, "hex_number", 0) \ + T(String, "string", 0) \ + T(Identifier, "identifier", 0) \ + /* type keywords */ \ + K(Ether, "ether", 0) \ + K(Wei, "wei", 0) \ + K(Hex, "hex", 0) \ + K(Boolean, "boolean", 0) \ + /* special keywords */ \ + K(Left, "left", 0) \ + K(Library, "library", 0) \ + K(Right, "right", 0) \ + K(Failure, "FAILURE", 0) \ + K(Storage, "storage", 0) \ + K(Gas, "gas", 0) \ namespace soltest { @@ -207,6 +208,9 @@ struct FunctionCallExpectations raw += param.rawBytes; return raw; } + /// Gas used by function call + /// Should have values for Yul, YulOptimized, Legacy and LegacyOptimized + std::map gasUsed; }; /** diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 2ba3a9cad..aa34c2844 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -62,8 +62,6 @@ vector TestFileParser::parseFunctionCall { if (!accept(Token::Whitespace)) { - FunctionCall call; - /// If this is not the first call in the test, /// the last call to parseParameter could have eaten the /// new line already. This could only be fixed with a one @@ -77,78 +75,100 @@ vector TestFileParser::parseFunctionCall try { - if (accept(Token::Library, true)) + if (accept(Token::Gas, true)) { - expect(Token::Colon); - call.signature = m_scanner.currentLiteral(); - expect(Token::Identifier); - call.kind = FunctionCall::Kind::Library; - call.expectations.failure = false; - } - else if (accept(Token::Storage, true)) - { - expect(Token::Colon); - call.expectations.failure = false; - call.expectations.result.push_back(Parameter()); - // empty / non-empty is encoded as false / true - if (m_scanner.currentLiteral() == "empty") - call.expectations.result.back().rawBytes = bytes(1, uint8_t(false)); - else if (m_scanner.currentLiteral() == "nonempty") - call.expectations.result.back().rawBytes = bytes(1, uint8_t(true)); + if (calls.empty()) + BOOST_THROW_EXCEPTION(TestParserError("Expected function call before gas usage filter.")); + + string runType = m_scanner.currentLiteral(); + if (set{"ir", "irOptimized", "legacy", "legacyOptimized"}.count(runType) > 0) + { + m_scanner.scanNextToken(); + expect(Token::Colon); + if (calls.back().expectations.gasUsed.count(runType) > 0) + throw TestParserError("Gas usage expectation set multiple times."); + calls.back().expectations.gasUsed[runType] = u256(parseDecimalNumber()); + } else - BOOST_THROW_EXCEPTION(TestParserError("Expected \"empty\" or \"nonempty\".")); - call.kind = FunctionCall::Kind::Storage; - m_scanner.scanNextToken(); + BOOST_THROW_EXCEPTION(TestParserError( + "Expected \"ir\", \"irOptimized\", \"legacy\", or \"legacyOptimized\"." + )); } else { - bool lowLevelCall = false; - tie(call.signature, lowLevelCall) = parseFunctionSignature(); - if (lowLevelCall) - call.kind = FunctionCall::Kind::LowLevel; - else if (isBuiltinFunction(call.signature)) - call.kind = FunctionCall::Kind::Builtin; + FunctionCall call; - if (accept(Token::Comma, true)) - call.value = parseFunctionCallValue(); - - if (accept(Token::Colon, true)) - call.arguments = parseFunctionCallArguments(); - - if (accept(Token::Newline, true)) + if (accept(Token::Library, true)) { - call.displayMode = FunctionCall::DisplayMode::MultiLine; - m_lineNumber++; + expect(Token::Colon); + call.signature = m_scanner.currentLiteral(); + expect(Token::Identifier); + call.kind = FunctionCall::Kind::Library; + call.expectations.failure = false; } - - call.arguments.comment = parseComment(); - - if (accept(Token::Newline, true)) + else if (accept(Token::Storage, true)) { - call.displayMode = FunctionCall::DisplayMode::MultiLine; - m_lineNumber++; - } - - if (accept(Token::Arrow, true)) - { - call.omitsArrow = false; - call.expectations = parseFunctionCallExpectations(); - if (accept(Token::Newline, true)) - m_lineNumber++; + expect(Token::Colon); + call.expectations.failure = false; + call.expectations.result.push_back(Parameter()); + // empty / non-empty is encoded as false / true + if (m_scanner.currentLiteral() == "empty") + call.expectations.result.back().rawBytes = bytes(1, uint8_t(false)); + else if (m_scanner.currentLiteral() == "nonempty") + call.expectations.result.back().rawBytes = bytes(1, uint8_t(true)); + else + BOOST_THROW_EXCEPTION(TestParserError("Expected \"empty\" or \"nonempty\".")); + call.kind = FunctionCall::Kind::Storage; + m_scanner.scanNextToken(); } else { - call.expectations.failure = false; - call.displayMode = FunctionCall::DisplayMode::SingleLine; + bool lowLevelCall = false; + tie(call.signature, lowLevelCall) = parseFunctionSignature(); + if (lowLevelCall) + call.kind = FunctionCall::Kind::LowLevel; + + if (accept(Token::Comma, true)) + call.value = parseFunctionCallValue(); + + if (accept(Token::Colon, true)) + call.arguments = parseFunctionCallArguments(); + + if (accept(Token::Newline, true)) + { + call.displayMode = FunctionCall::DisplayMode::MultiLine; + m_lineNumber++; + } + + call.arguments.comment = parseComment(); + + if (accept(Token::Newline, true)) + { + call.displayMode = FunctionCall::DisplayMode::MultiLine; + m_lineNumber++; + } + + if (accept(Token::Arrow, true)) + { + call.omitsArrow = false; + call.expectations = parseFunctionCallExpectations(); + if (accept(Token::Newline, true)) + m_lineNumber++; + } + else + { + call.expectations.failure = false; + call.displayMode = FunctionCall::DisplayMode::SingleLine; + } + + call.expectations.comment = parseComment(); + + if (call.signature == "constructor()") + call.kind = FunctionCall::Kind::Constructor; } - call.expectations.comment = parseComment(); - - if (call.signature == "constructor()") - call.kind = FunctionCall::Kind::Constructor; + calls.emplace_back(std::move(call)); } - - calls.emplace_back(std::move(call)); } catch (TestParserError const& _e) { @@ -506,6 +526,7 @@ void TestFileParser::Scanner::scanNextToken() if (_literal == "hex") return {Token::Hex, ""}; if (_literal == "FAILURE") return {Token::Failure, ""}; if (_literal == "storage") return {Token::Storage, ""}; + if (_literal == "gas") return {Token::Gas, ""}; return {Token::Identifier, _literal}; }; diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index e13fccf09..cc5cb8136 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -93,7 +93,6 @@ string TestFunctionCall::format( if (!m_call.arguments.parameters.at(0).format.newline) stream << ws; stream << output; - } /// Formats comments on the function parameters and the arrow taking @@ -204,6 +203,8 @@ string TestFunctionCall::format( stream << comment << m_call.expectations.comment << comment; } } + + stream << formatGasExpectations(_linePrefix); }; formatOutput(m_call.displayMode == FunctionCall::DisplayMode::SingleLine); @@ -319,6 +320,17 @@ string TestFunctionCall::formatRawParameters( return os.str(); } +string TestFunctionCall::formatGasExpectations(string const& _linePrefix) const +{ + stringstream os; + for (auto const& [runType, gasUsed]: m_call.expectations.gasUsed) + if (runType != get<0>(m_gasCost)) + os << endl << _linePrefix << "// gas " << runType << ": " << gasUsed.str(); + if (!get<0>(m_gasCost).empty()) + os << endl << _linePrefix << "// gas " << get<0>(m_gasCost) << ": " << get<1>(m_gasCost).str(); + return os.str(); +} + void TestFunctionCall::reset() { m_rawBytes = bytes{}; diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index 7daac093a..a21f0b779 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -79,6 +79,7 @@ public: void calledNonExistingFunction() { m_calledNonExistingFunction = true; } void setFailure(const bool _failure) { m_failure = _failure; } void setRawBytes(const bytes _rawBytes) { m_rawBytes = _rawBytes; } + void setGasCost(std::string _runType, u256 _gasCost) { m_gasCost = {std::move(_runType), std::move(_gasCost)}; } void setContractABI(Json::Value _contractABI) { m_contractABI = std::move(_contractABI); } private: @@ -116,6 +117,9 @@ private: std::string const& _linePrefix = "" ) const; + /// Formats gas usage expectations one per line + std::string formatGasExpectations(std::string const& _linePrefix) const; + /// Compares raw expectations (which are converted to a byte representation before), /// and also the expected transaction status of the function call to the actual test results. bool matchesExpectation() const; @@ -124,6 +128,8 @@ private: FunctionCall m_call; /// Result of the actual call been made. bytes m_rawBytes = bytes{}; + /// Actual gas cost for the type of the run + std::tuple m_gasCost; /// Transaction status of the actual call. False in case of a REVERT or any other failure. bool m_failure = true; /// JSON object which holds the contract ABI and that is used to set the output formatting diff --git a/test/libsolidity/util/TestFunctionCallTests.cpp b/test/libsolidity/util/TestFunctionCallTests.cpp index dc3030384..cdda77dde 100644 --- a/test/libsolidity/util/TestFunctionCallTests.cpp +++ b/test/libsolidity/util/TestFunctionCallTests.cpp @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline) bytes expectedBytes = toBigEndian(u256{1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(uint8)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline_signed_encoding) bytes expectedBytes = toBigEndian(u256{1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(uint8)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_multiline) bytes expectedBytes = toBigEndian(u256{1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter result{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{result}, false, string{}}; + FunctionCallExpectations expectations{vector{result}, false, string{}, {}}; FunctionCallArgs arguments{vector{}, string{}}; FunctionCall call{"f(uint8)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(format_multiple_unsigned_singleline) bytes expectedBytes = toBigEndian(u256{1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param, param}, false, string{}}; + FunctionCallExpectations expectations{vector{param, param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param, param}, string{}}; FunctionCall call{"f(uint8, uint8)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(format_signed_singleline) bytes expectedBytes = toBigEndian(u256{-1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "-1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(int8)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(format_hex_singleline) bytes expectedBytes = result + bytes(32 - result.size(), 0); ABIType abiType{ABIType::Hex, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "0x31", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(bytes32)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(format_hex_string_singleline) bytes expectedBytes = fromHex("4200ef"); ABIType abiType{ABIType::HexString, ABIType::AlignLeft, 3}; Parameter param{expectedBytes, "hex\"4200ef\"", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(string)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(format_bool_true_singleline) bytes expectedBytes = toBigEndian(u256{true}); ABIType abiType{ABIType::Boolean, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "true", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(bool)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(format_bool_false_singleline) bytes expectedBytes = toBigEndian(u256{false}); ABIType abiType{ABIType::Boolean, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "false", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(bool)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -199,7 +199,7 @@ BOOST_AUTO_TEST_CASE(format_bool_left_singleline) bytes expectedBytes = toBigEndian(u256{false}); ABIType abiType{ABIType::Boolean, ABIType::AlignLeft, 32}; Parameter param{expectedBytes, "left(false)", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(bool)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -214,7 +214,7 @@ BOOST_AUTO_TEST_CASE(format_hex_number_right_singleline) bytes expectedBytes = result + bytes(32 - result.size(), 0); ABIType abiType{ABIType::Hex, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "right(0x42)", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(bool)", {0}, arguments, expectations}; call.omitsArrow = false; @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(format_empty_byte_range) bytes expectedBytes; ABIType abiType{ABIType::None, ABIType::AlignNone, 0}; Parameter param{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{param}, false, string{}}; + FunctionCallExpectations expectations{vector{param}, false, string{}, {}}; FunctionCallArgs arguments{vector{}, string{}}; FunctionCall call{"f()", {0}, arguments, expectations}; call.omitsArrow = false; @@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(format_failure_singleline) bytes expectedBytes = toBigEndian(u256{1}); ABIType abiType{ABIType::UnsignedDec, ABIType::AlignRight, 32}; Parameter param{expectedBytes, "1", abiType, FormatInfo{}}; - FunctionCallExpectations expectations{vector{}, true, string{}}; + FunctionCallExpectations expectations{vector{}, true, string{}, {}}; FunctionCallArgs arguments{vector{param}, string{}}; FunctionCall call{"f(uint8)", {0}, arguments, expectations}; call.omitsArrow = false; From 5ea97a5d439ed91ee7f3a7dd581bfb698d680938 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 29 Jan 2021 10:40:03 +0100 Subject: [PATCH 02/13] Running gas tests only on tests having expectations. --- test/libsolidity/SemanticTest.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 74bf508f7..417ed36f9 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -324,10 +324,12 @@ bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _comp string setting = (_compileViaYul ? "ir"s : "legacy"s) + (m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : ""); + + if (io_test.call().expectations.gasUsed.count(setting) == 0) + return true; + io_test.setGasCost(setting, m_gasUsed); - return - io_test.call().expectations.gasUsed.count(setting) > 0 && - m_gasUsed == io_test.call().expectations.gasUsed.at(setting); + return m_gasUsed == io_test.call().expectations.gasUsed.at(setting); } void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const From 515f15f7a37b5f9810d334883821f387e54691ff Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 29 Jan 2021 10:55:34 +0100 Subject: [PATCH 03/13] Small style fix for SemanticTest constructor. --- test/libsolidity/SemanticTest.cpp | 7 ++++++- test/libsolidity/SemanticTest.h | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 417ed36f9..3f6de0d26 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -45,7 +45,12 @@ using namespace boost::unit_test; namespace fs = boost::filesystem; -SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVersion, vector const& _vmPaths, bool enforceViaYul): +SemanticTest::SemanticTest( + string const& _filename, + langutil::EVMVersion _evmVersion, + vector const& _vmPaths, + bool enforceViaYul +): SolidityExecutionFramework(_evmVersion, _vmPaths), EVMVersionRestrictedTestCase(_filename), m_sources(m_reader.sources()), diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index bb2960ab2..41f2790f8 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -42,7 +42,12 @@ public: static std::unique_ptr create(Config const& _options) { return std::make_unique(_options.filename, _options.evmVersion, _options.vmPaths, _options.enforceCompileViaYul); } - explicit SemanticTest(std::string const& _filename, langutil::EVMVersion _evmVersion, std::vector const& _vmPaths, bool _enforceViaYul = false); + explicit SemanticTest( + std::string const& _filename, + langutil::EVMVersion _evmVersion, + std::vector const& _vmPaths, + bool _enforceViaYul = false + ); TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override; void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool _formatted = false) const override; From aed3832b27352610de8b386166c26d13abb276ee Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 29 Jan 2021 14:07:22 +0100 Subject: [PATCH 04/13] Implementing enforcing gas expectations in isoltest. Co-authored-by: Daniel Kirchner --- test/Common.cpp | 7 +++++++ test/Common.h | 2 ++ test/TestCase.h | 4 +++- test/boostTest.cpp | 9 ++++++++- test/libsolidity/SemanticTest.cpp | 20 ++++++++++++++++---- test/libsolidity/SemanticTest.h | 17 +++++++++++++++-- test/tools/IsolTestOptions.cpp | 2 ++ test/tools/isoltest.cpp | 4 +++- 8 files changed, 56 insertions(+), 9 deletions(-) diff --git a/test/Common.cpp b/test/Common.cpp index 30d2f3d78..af03a1522 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -103,6 +103,8 @@ CommonOptions::CommonOptions(std::string _caption): ("no-smt", po::bool_switch(&disableSMT), "disable SMT checker") ("optimize", po::bool_switch(&optimize), "enables optimization") ("enforce-via-yul", po::bool_switch(&enforceViaYul), "Enforce compiling all tests via yul to see if additional tests can be activated.") + ("enforce-gas-cost", po::bool_switch(&enforceGasTest), "Enforce gas cost expectations in semantic tests.") + ("enforce-gas-cost-min-value", po::value(&enforceGasTestMinValue), "Threshold value when enforcing gas cost expectations.") ("abiencoderv1", po::bool_switch(&useABIEncoderV1), "enables abi encoder v1") ("show-messages", po::bool_switch(&showMessages), "enables message output") ("show-metadata", po::bool_switch(&showMetadata), "enables metadata output"); @@ -120,6 +122,11 @@ void CommonOptions::validate() const ConfigException, "Invalid test path specified." ); + assertThrow( + !enforceGasTest || evmVersion() == langutil::EVMVersion{}, + ConfigException, + "Gas costs can only be enforced on latest evm version." + ); } diff --git a/test/Common.h b/test/Common.h index 57a7c773d..ba6d8f10d 100644 --- a/test/Common.h +++ b/test/Common.h @@ -56,6 +56,8 @@ struct CommonOptions: boost::noncopyable bool ewasm = false; bool optimize = false; bool enforceViaYul = false; + bool enforceGasTest = false; + u256 enforceGasTestMinValue = 100000; bool disableSMT = false; bool useABIEncoderV1 = false; bool showMessages = false; diff --git a/test/TestCase.h b/test/TestCase.h index 65cc4eeb6..f4699db39 100644 --- a/test/TestCase.h +++ b/test/TestCase.h @@ -40,7 +40,9 @@ public: std::string filename; langutil::EVMVersion evmVersion; std::vector vmPaths; - bool enforceCompileViaYul; + bool enforceCompileViaYul = false; + bool enforceGasCost = false; + u256 enforceGasCostMinValue; }; enum class TestResult { Success, Failure, FatalError }; diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 36620337e..0eaa5b65e 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -71,7 +71,14 @@ int registerTests( { int numTestsAdded = 0; fs::path fullpath = _basepath / _path; - TestCase::Config config{fullpath.string(), solidity::test::CommonOptions::get().evmVersion(), solidity::test::CommonOptions::get().vmPaths, _enforceViaYul}; + TestCase::Config config{ + fullpath.string(), + solidity::test::CommonOptions::get().evmVersion(), + solidity::test::CommonOptions::get().vmPaths, + _enforceViaYul, + /* enforceGasCost */ false, + 0 + }; if (fs::is_directory(fullpath)) { test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string()); diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 3f6de0d26..555ba1804 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -49,13 +49,17 @@ SemanticTest::SemanticTest( string const& _filename, langutil::EVMVersion _evmVersion, vector const& _vmPaths, - bool enforceViaYul + bool _enforceViaYul, + bool _enforceGasCost, + u256 _enforceGasCostMinValue ): SolidityExecutionFramework(_evmVersion, _vmPaths), EVMVersionRestrictedTestCase(_filename), m_sources(m_reader.sources()), m_lineOffset(m_reader.lineNumber()), - m_enforceViaYul(enforceViaYul) + m_enforceViaYul(_enforceViaYul), + m_enforceGasCost(_enforceGasCost), + m_enforceGasCostMinValue(_enforceGasCostMinValue) { string choice = m_reader.stringSetting("compileViaYul", "default"); if (choice == "also") @@ -326,15 +330,23 @@ TestCase::TestResult SemanticTest::runTest( bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const { + if (m_evmVersion != EVMVersion{}) + return true; + string setting = (_compileViaYul ? "ir"s : "legacy"s) + (m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : ""); - if (io_test.call().expectations.gasUsed.count(setting) == 0) + if ( + (!m_enforceGasCost || m_gasUsed < m_enforceGasCostMinValue) && + io_test.call().expectations.gasUsed.count(setting) == 0 + ) return true; io_test.setGasCost(setting, m_gasUsed); - return m_gasUsed == io_test.call().expectations.gasUsed.at(setting); + return + io_test.call().expectations.gasUsed.count(setting) > 0 && + m_gasUsed == io_test.call().expectations.gasUsed.at(setting); } void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const diff --git a/test/libsolidity/SemanticTest.h b/test/libsolidity/SemanticTest.h index 41f2790f8..9520c1bc7 100644 --- a/test/libsolidity/SemanticTest.h +++ b/test/libsolidity/SemanticTest.h @@ -40,13 +40,24 @@ class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrict { public: static std::unique_ptr create(Config const& _options) - { return std::make_unique(_options.filename, _options.evmVersion, _options.vmPaths, _options.enforceCompileViaYul); } + { + return std::make_unique( + _options.filename, + _options.evmVersion, + _options.vmPaths, + _options.enforceCompileViaYul, + _options.enforceGasCost, + _options.enforceGasCostMinValue + ); + } explicit SemanticTest( std::string const& _filename, langutil::EVMVersion _evmVersion, std::vector const& _vmPaths, - bool _enforceViaYul = false + bool _enforceViaYul = false, + bool _enforceGasCost = false, + u256 _enforceGasCostMinValue = 100000 ); TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override; @@ -80,6 +91,8 @@ private: std::map m_builtins{}; bool m_gasCostFailure = false; + bool m_enforceGasCost = false; + u256 m_enforceGasCostMinValue; }; } diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index 763a0b3b7..785179132 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -76,6 +76,8 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv) return false; } enforceViaYul = true; + enforceGasTest = (evmVersion() == langutil::EVMVersion{}); + enforceGasTestMinValue = 100000; return res; } diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 0d6a92e5b..bd5f48a4a 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -162,7 +162,9 @@ TestTool::Result TestTool::process() m_path.string(), m_options.evmVersion(), m_options.vmPaths, - m_options.enforceViaYul + m_options.enforceViaYul, + m_options.enforceGasTest, + m_options.enforceGasTestMinValue }); if (m_test->shouldRun()) switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted)) From cf59d7fc137b7ba3f90bf37deb50659dab6d274f Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Mon, 1 Feb 2021 10:37:03 +0100 Subject: [PATCH 05/13] Making order of gas expectations deterministic. --- test/libsolidity/util/TestFunctionCall.cpp | 8 +++----- test/libsolidity/util/TestFunctionCall.h | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index cc5cb8136..24795ee8b 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -323,11 +323,9 @@ string TestFunctionCall::formatRawParameters( string TestFunctionCall::formatGasExpectations(string const& _linePrefix) const { stringstream os; - for (auto const& [runType, gasUsed]: m_call.expectations.gasUsed) - if (runType != get<0>(m_gasCost)) - os << endl << _linePrefix << "// gas " << runType << ": " << gasUsed.str(); - if (!get<0>(m_gasCost).empty()) - os << endl << _linePrefix << "// gas " << get<0>(m_gasCost) << ": " << get<1>(m_gasCost).str(); + for (auto const& [runType, gasUsed]: m_gasCosts) + if (!runType.empty()) + os << endl << _linePrefix << "// gas " << runType << ": " << (gasUsed.str()); return os.str(); } diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index a21f0b779..de9fb4533 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -42,7 +42,7 @@ namespace solidity::frontend::test class TestFunctionCall { public: - TestFunctionCall(FunctionCall _call): m_call(std::move(_call)) {} + TestFunctionCall(FunctionCall _call): m_call(std::move(_call)), m_gasCosts(m_call.expectations.gasUsed) {} /// Formats this function call test and applies the format that was detected during parsing. /// If _renderResult is false, the expected result of the call will be used, if it's true @@ -79,7 +79,7 @@ public: void calledNonExistingFunction() { m_calledNonExistingFunction = true; } void setFailure(const bool _failure) { m_failure = _failure; } void setRawBytes(const bytes _rawBytes) { m_rawBytes = _rawBytes; } - void setGasCost(std::string _runType, u256 _gasCost) { m_gasCost = {std::move(_runType), std::move(_gasCost)}; } + void setGasCost(std::string const& _runType, u256 const& _gasCost) { m_gasCosts[_runType] = _gasCost; } void setContractABI(Json::Value _contractABI) { m_contractABI = std::move(_contractABI); } private: @@ -128,8 +128,8 @@ private: FunctionCall m_call; /// Result of the actual call been made. bytes m_rawBytes = bytes{}; - /// Actual gas cost for the type of the run - std::tuple m_gasCost; + /// Actual gas costs + std::map m_gasCosts; /// Transaction status of the actual call. False in case of a REVERT or any other failure. bool m_failure = true; /// JSON object which holds the contract ABI and that is used to set the output formatting From 12ef273d064fd8719e914c5498e5c837b114b8dc Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 12 Feb 2021 12:33:49 +0100 Subject: [PATCH 06/13] Setting metadata has and version type for semantic tests to be empty. --- test/libsolidity/SemanticTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 555ba1804..9f9bbbd16 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -114,6 +114,12 @@ SemanticTest::SemanticTest( parseExpectations(m_reader.stream()); soltestAssert(!m_tests.empty(), "No tests specified in " + _filename); + + if (_evmVersion == EVMVersion{}) + { + m_compiler.setVersionType(CompilerStack::VersionType::Empty); + m_compiler.setMetadataHash(CompilerStack::MetadataHash::None); + } } TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted) From 2c575db0eacad77bac97ff8384a5bd3f9b2ba089 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Tue, 9 Mar 2021 21:27:38 +0100 Subject: [PATCH 07/13] Show both expected and obtained gas expectations when failure happens. --- test/libsolidity/SemanticTest.cpp | 29 +++++++++------------- test/libsolidity/util/TestFunctionCall.cpp | 9 ++++--- test/libsolidity/util/TestFunctionCall.h | 15 ++++++++--- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 9f9bbbd16..9d44f975d 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -258,7 +258,10 @@ TestCase::TestResult SemanticTest::runTest( bool outputMismatch = (output != test.call().expectations.rawBytes()); if (!outputMismatch && !checkGasCostExpectation(test, _compileViaYul)) + { + success = false; m_gasCostFailure = true; + } // Pre byzantium, it was not possible to return failure data, so we disregard // output mismatch for those EVM versions. @@ -291,7 +294,7 @@ TestCase::TestResult SemanticTest::runTest( for (TestFunctionCall const& test: m_tests) { ErrorReporter errorReporter; - _stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl; + _stream << test.format(errorReporter, _linePrefix, false, _formatted, false) << endl; _stream << errorReporter.format(_linePrefix, _formatted); } _stream << endl; @@ -299,7 +302,7 @@ TestCase::TestResult SemanticTest::runTest( for (TestFunctionCall const& test: m_tests) { ErrorReporter errorReporter; - _stream << test.format(errorReporter, _linePrefix, true, _formatted) << endl; + _stream << test.format(errorReporter, _linePrefix, !m_gasCostFailure, _formatted, m_gasCostFailure) << endl; _stream << errorReporter.format(_linePrefix, _formatted); } AnsiColorized(_stream, _formatted, {BOLD, RED}) @@ -318,25 +321,12 @@ TestCase::TestResult SemanticTest::runTest( return TestResult::Failure; } - if (m_gasCostFailure) - { - AnsiColorized(_stream, _formatted, {BOLD, CYAN}) - << _linePrefix << "Gas results missing or wrong, obtained result:" << endl; - for (auto const& test: m_tests) - { - ErrorReporter errorReporter; - _stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl; - _stream << errorReporter.format(_linePrefix, _formatted); - } - return TestResult::Failure; - } - return TestResult::Success; } bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const { - if (m_evmVersion != EVMVersion{}) + if (m_evmVersion != EVMVersion{} || solidity::test::CommonOptions::get().useABIEncoderV1) return true; string setting = @@ -402,7 +392,12 @@ void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) const { for (TestFunctionCall const& test: m_tests) - _stream << test.format("", /* _renderResult = */ !m_gasCostFailure, /* _highlight = */ false) << endl; + _stream << test.format( + "", + /* _renderResult = */ !m_gasCostFailure, + /* _highlight = */ false, + /* _renderGasCostResult */ m_gasCostFailure + ) << endl; } void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix) diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 24795ee8b..9166e0aca 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -36,7 +36,8 @@ string TestFunctionCall::format( ErrorReporter& _errorReporter, string const& _linePrefix, bool const _renderResult, - bool const _highlight + bool const _highlight, + bool const _renderGasCostResult ) const { stringstream stream; @@ -204,7 +205,7 @@ string TestFunctionCall::format( } } - stream << formatGasExpectations(_linePrefix); + stream << formatGasExpectations(_linePrefix, _renderGasCostResult); }; formatOutput(m_call.displayMode == FunctionCall::DisplayMode::SingleLine); @@ -320,10 +321,10 @@ string TestFunctionCall::formatRawParameters( return os.str(); } -string TestFunctionCall::formatGasExpectations(string const& _linePrefix) const +string TestFunctionCall::formatGasExpectations(string const& _linePrefix, bool const _renderGasCostResult) const { stringstream os; - for (auto const& [runType, gasUsed]: m_gasCosts) + for (auto const& [runType, gasUsed]: (_renderGasCostResult ? m_gasCosts : m_call.expectations.gasUsed)) if (!runType.empty()) os << endl << _linePrefix << "// gas " << runType << ": " << (gasUsed.str()); return os.str(); diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index de9fb4533..c6a215a9d 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -49,6 +49,8 @@ public: /// the actual result is used. /// If _highlight is false, it's formatted without colorized highlighting. If it's true, AnsiColorized is /// used to apply a colorized highlighting. + /// If __renderGasCostResult is false, the expected gas costs will be used, if it's true + /// the actual gas costs will be used /// If test expectations do not match, the contract ABI is consulted in order to get the /// right encoding for returned bytes, based on the parsed return types. /// Reports warnings and errors to the error reporter. @@ -56,7 +58,8 @@ public: ErrorReporter& _errorReporter, std::string const& _linePrefix = "", bool const _renderResult = false, - bool const _highlight = false + bool const _highlight = false, + bool const _renderGasCostResult = false ) const; /// Overloaded version that passes an error reporter which is never used outside @@ -64,11 +67,12 @@ public: std::string format( std::string const& _linePrefix = "", bool const _renderResult = false, - bool const _highlight = false + bool const _highlight = false, + bool const _renderGasCostResult = false ) const { ErrorReporter reporter; - return format(reporter, _linePrefix, _renderResult, _highlight); + return format(reporter, _linePrefix, _renderResult, _highlight, _renderGasCostResult); } /// Resets current results in case the function was called and the result @@ -118,7 +122,10 @@ private: ) const; /// Formats gas usage expectations one per line - std::string formatGasExpectations(std::string const& _linePrefix) const; + std::string formatGasExpectations( + std::string const& _linePrefix, + bool const _renderGasCostResult + ) const; /// Compares raw expectations (which are converted to a byte representation before), /// and also the expected transaction status of the function call to the actual test results. From 14a37311829ec61d91e58348f45fd195244f6901 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Thu, 4 Feb 2021 17:53:27 +0100 Subject: [PATCH 08/13] Don't run gas for ir if it is not explicitely added to expectations. --- test/libsolidity/SemanticTest.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 9d44f975d..d39c2c704 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -326,16 +326,21 @@ TestCase::TestResult SemanticTest::runTest( bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _compileViaYul) const { - if (m_evmVersion != EVMVersion{} || solidity::test::CommonOptions::get().useABIEncoderV1) - return true; - string setting = (_compileViaYul ? "ir"s : "legacy"s) + (m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : ""); + // We don't check gas if evm is not set to default version + // or in case we run abiencoderv1 + // or gas used less than threshold for enforcing feature + // or setting is "ir" and it's not included in expectations if ( - (!m_enforceGasCost || m_gasUsed < m_enforceGasCostMinValue) && - io_test.call().expectations.gasUsed.count(setting) == 0 + m_evmVersion != EVMVersion{} || + solidity::test::CommonOptions::get().useABIEncoderV1 || + ( + (!m_enforceGasCost || setting == "ir" || m_gasUsed < m_enforceGasCostMinValue) && + io_test.call().expectations.gasUsed.count(setting) == 0 + ) ) return true; From 2b14efbbcc4de3bde7bdc7fae3e951d8bd249ed0 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Thu, 4 Feb 2021 19:18:09 +0100 Subject: [PATCH 09/13] Adding debug info on gas costs when updating gas values. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil ƚliwak --- test/libsolidity/SemanticTest.cpp | 21 ++++++-- test/libsolidity/util/TestFunctionCall.cpp | 48 ++++++++++++++----- test/libsolidity/util/TestFunctionCall.h | 31 +++++++----- .../util/TestFunctionCallTests.cpp | 10 ++-- 4 files changed, 78 insertions(+), 32 deletions(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index d39c2c704..e138da5fb 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -294,7 +294,13 @@ TestCase::TestResult SemanticTest::runTest( for (TestFunctionCall const& test: m_tests) { ErrorReporter errorReporter; - _stream << test.format(errorReporter, _linePrefix, false, _formatted, false) << endl; + _stream << test.format( + errorReporter, + _linePrefix, + TestFunctionCall::RenderMode::ExpectedValuesExpectedGas, + _formatted, + /* _interactivePrint */ true + ) << endl; _stream << errorReporter.format(_linePrefix, _formatted); } _stream << endl; @@ -302,7 +308,13 @@ TestCase::TestResult SemanticTest::runTest( for (TestFunctionCall const& test: m_tests) { ErrorReporter errorReporter; - _stream << test.format(errorReporter, _linePrefix, !m_gasCostFailure, _formatted, m_gasCostFailure) << endl; + _stream << test.format( + errorReporter, + _linePrefix, + m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas, + _formatted, + /* _interactivePrint */ true + ) << endl; _stream << errorReporter.format(_linePrefix, _formatted); } AnsiColorized(_stream, _formatted, {BOLD, RED}) @@ -399,9 +411,8 @@ void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) con for (TestFunctionCall const& test: m_tests) _stream << test.format( "", - /* _renderResult = */ !m_gasCostFailure, - /* _highlight = */ false, - /* _renderGasCostResult */ m_gasCostFailure + m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas, + /* _highlight = */ false ) << endl; } diff --git a/test/libsolidity/util/TestFunctionCall.cpp b/test/libsolidity/util/TestFunctionCall.cpp index 9166e0aca..6adf4fcaf 100644 --- a/test/libsolidity/util/TestFunctionCall.cpp +++ b/test/libsolidity/util/TestFunctionCall.cpp @@ -35,9 +35,9 @@ using Token = soltest::Token; string TestFunctionCall::format( ErrorReporter& _errorReporter, string const& _linePrefix, - bool const _renderResult, + RenderMode _renderMode, bool const _highlight, - bool const _renderGasCostResult + bool const _interactivePrint ) const { stringstream stream; @@ -66,9 +66,12 @@ string TestFunctionCall::format( stream << _linePrefix << newline << ws << "storage" << colon << ws; soltestAssert(m_rawBytes.size() == 1, ""); soltestAssert(m_call.expectations.rawBytes().size() == 1, ""); - bool isEmpty = _renderResult ? m_rawBytes.front() == 0 : m_call.expectations.rawBytes().front() == 0; + bool isEmpty = + _renderMode == RenderMode::ActualValuesExpectedGas ? + m_rawBytes.front() == 0 : + m_call.expectations.rawBytes().front() == 0; string output = isEmpty ? "empty" : "nonempty"; - if (_renderResult && !matchesExpectation()) + if (_renderMode == RenderMode::ActualValuesExpectedGas && !matchesExpectation()) AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << output; else stream << output; @@ -105,7 +108,7 @@ string TestFunctionCall::format( if (m_call.omitsArrow) { - if (_renderResult && (m_failure || !matchesExpectation())) + if (_renderMode == RenderMode::ActualValuesExpectedGas && (m_failure || !matchesExpectation())) stream << ws << arrow; } else @@ -124,11 +127,11 @@ string TestFunctionCall::format( /// Format either the expected output or the actual result output string result; - if (!_renderResult) + if (_renderMode != RenderMode::ActualValuesExpectedGas) { bool const isFailure = m_call.expectations.failure; result = isFailure ? - formatFailure(_errorReporter, m_call, m_rawBytes, _renderResult, highlight) : + formatFailure(_errorReporter, m_call, m_rawBytes, /* _renderResult */ false, highlight) : formatRawParameters(m_call.expectations.result); if (!result.empty()) AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << ws << result; @@ -141,7 +144,7 @@ string TestFunctionCall::format( bytes output = m_rawBytes; bool const isFailure = m_failure; result = isFailure ? - formatFailure(_errorReporter, m_call, output, _renderResult, highlight) : + formatFailure(_errorReporter, m_call, output, _renderMode == RenderMode::ActualValuesExpectedGas, highlight) : matchesExpectation() ? formatRawParameters(m_call.expectations.result) : formatBytesParameters( @@ -205,7 +208,7 @@ string TestFunctionCall::format( } } - stream << formatGasExpectations(_linePrefix, _renderGasCostResult); + stream << formatGasExpectations(_linePrefix, _renderMode == RenderMode::ExpectedValuesActualGas, _interactivePrint); }; formatOutput(m_call.displayMode == FunctionCall::DisplayMode::SingleLine); @@ -321,12 +324,35 @@ string TestFunctionCall::formatRawParameters( return os.str(); } -string TestFunctionCall::formatGasExpectations(string const& _linePrefix, bool const _renderGasCostResult) const +string TestFunctionCall::formatGasExpectations( + string const& _linePrefix, + bool _useActualCost, + bool _showDifference +) const { stringstream os; - for (auto const& [runType, gasUsed]: (_renderGasCostResult ? m_gasCosts : m_call.expectations.gasUsed)) + for (auto const& [runType, gasUsed]: (_useActualCost ? m_gasCosts : m_call.expectations.gasUsed)) if (!runType.empty()) + { + bool differentResults = + m_gasCosts.count(runType) > 0 && + m_call.expectations.gasUsed.count(runType) > 0 && + m_gasCosts.at(runType) != m_call.expectations.gasUsed.at(runType); + + s256 difference = 0; + if (differentResults) + difference = + static_cast(m_gasCosts.at(runType)) - + static_cast(m_call.expectations.gasUsed.at(runType)); + int percent = 0; + if (differentResults) + percent = static_cast( + 100.0 * (static_cast(difference) / static_cast(m_call.expectations.gasUsed.at(runType))) + ); os << endl << _linePrefix << "// gas " << runType << ": " << (gasUsed.str()); + if (_showDifference && differentResults && _useActualCost) + os << " [" << showpos << difference << " (" << percent << "%)]"; + } return os.str(); } diff --git a/test/libsolidity/util/TestFunctionCall.h b/test/libsolidity/util/TestFunctionCall.h index c6a215a9d..839c86553 100644 --- a/test/libsolidity/util/TestFunctionCall.h +++ b/test/libsolidity/util/TestFunctionCall.h @@ -42,37 +42,45 @@ namespace solidity::frontend::test class TestFunctionCall { public: + enum class RenderMode + { + ExpectedValuesExpectedGas, + ActualValuesExpectedGas, + ExpectedValuesActualGas + }; + TestFunctionCall(FunctionCall _call): m_call(std::move(_call)), m_gasCosts(m_call.expectations.gasUsed) {} /// Formats this function call test and applies the format that was detected during parsing. - /// If _renderResult is false, the expected result of the call will be used, if it's true - /// the actual result is used. + /// _renderMode determines the source of values to be inserted into the updated test expectations. + /// RenderMode::ActualValuesExpectedGas: use the values produced by the test but for gas preserve the original expectations, + /// RenderMode::ExpectedValuesExpectedGas: preserve the original expectations for both gas and other values, + /// RenderMode::ExpectedValuesActualGas: use the original expectations but for gas use actual values, /// If _highlight is false, it's formatted without colorized highlighting. If it's true, AnsiColorized is /// used to apply a colorized highlighting. - /// If __renderGasCostResult is false, the expected gas costs will be used, if it's true - /// the actual gas costs will be used + /// If _interactivePrint is true, we are producing output that will be interactively shown to the user + /// in the terminal rather than used to update the expectations in the test file. /// If test expectations do not match, the contract ABI is consulted in order to get the /// right encoding for returned bytes, based on the parsed return types. /// Reports warnings and errors to the error reporter. std::string format( ErrorReporter& _errorReporter, std::string const& _linePrefix = "", - bool const _renderResult = false, + RenderMode _renderMode = RenderMode::ExpectedValuesExpectedGas, bool const _highlight = false, - bool const _renderGasCostResult = false + bool const _interactivePrint = false ) const; /// Overloaded version that passes an error reporter which is never used outside /// of this function. std::string format( std::string const& _linePrefix = "", - bool const _renderResult = false, - bool const _highlight = false, - bool const _renderGasCostResult = false + RenderMode const _renderMode = RenderMode::ExpectedValuesExpectedGas, + bool const _highlight = false ) const { ErrorReporter reporter; - return format(reporter, _linePrefix, _renderResult, _highlight, _renderGasCostResult); + return format(reporter, _linePrefix, _renderMode, _highlight); } /// Resets current results in case the function was called and the result @@ -124,7 +132,8 @@ private: /// Formats gas usage expectations one per line std::string formatGasExpectations( std::string const& _linePrefix, - bool const _renderGasCostResult + bool _useActualCost, + bool _showDifference ) const; /// Compares raw expectations (which are converted to a byte representation before), diff --git a/test/libsolidity/util/TestFunctionCallTests.cpp b/test/libsolidity/util/TestFunctionCallTests.cpp index cdda77dde..e321ac676 100644 --- a/test/libsolidity/util/TestFunctionCallTests.cpp +++ b/test/libsolidity/util/TestFunctionCallTests.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline) test.setRawBytes(toBigEndian(u256{2})); test.setFailure(false); - BOOST_REQUIRE_EQUAL(test.format("", true), "// f(uint8): 1 -> 2"); + BOOST_REQUIRE_EQUAL(test.format("", TestFunctionCall::RenderMode::ActualValuesExpectedGas), "// f(uint8): 1 -> 2"); } BOOST_AUTO_TEST_CASE(format_unsigned_singleline_signed_encoding) @@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(format_unsigned_singleline_signed_encoding) test.setRawBytes(toBigEndian(u256{-1})); test.setFailure(false); - BOOST_REQUIRE_EQUAL(test.format("", true), "// f(uint8): 1 -> -1"); + BOOST_REQUIRE_EQUAL(test.format("", TestFunctionCall::RenderMode::ActualValuesExpectedGas), "// f(uint8): 1 -> -1"); } BOOST_AUTO_TEST_CASE(format_unsigned_multiline) @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(format_signed_singleline) test.setRawBytes(toBigEndian(u256{-2})); test.setFailure(false); - BOOST_REQUIRE_EQUAL(test.format("", true), "// f(int8): -1 -> -2"); + BOOST_REQUIRE_EQUAL(test.format("", TestFunctionCall::RenderMode::ActualValuesExpectedGas), "// f(int8): -1 -> -2"); } BOOST_AUTO_TEST_CASE(format_hex_singleline) @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(format_hex_singleline) test.setRawBytes(actualBytes); test.setFailure(false); - BOOST_REQUIRE_EQUAL(test.format("", true), "// f(bytes32): 0x31 -> 0x32"); + BOOST_REQUIRE_EQUAL(test.format("", TestFunctionCall::RenderMode::ActualValuesExpectedGas), "// f(bytes32): 0x31 -> 0x32"); } BOOST_AUTO_TEST_CASE(format_hex_string_singleline) @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(format_bool_true_singleline) test.setRawBytes(actualBytes); test.setFailure(false); - BOOST_REQUIRE_EQUAL(test.format("", true), "// f(bool): true -> false"); + BOOST_REQUIRE_EQUAL(test.format("", TestFunctionCall::RenderMode::ActualValuesExpectedGas), "// f(bool): true -> false"); } BOOST_AUTO_TEST_CASE(format_bool_false_singleline) From 06171a31005f9f19d1b690828b7b8f4602f3132d Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 12 Feb 2021 12:55:07 +0100 Subject: [PATCH 10/13] Changing enforceGasCost functionality. --- test/Common.cpp | 23 +++++++++++++++-------- test/boostTest.cpp | 4 ++-- test/libsolidity/SemanticTest.cpp | 15 ++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/test/Common.cpp b/test/Common.cpp index af03a1522..8406727d3 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -103,8 +103,8 @@ CommonOptions::CommonOptions(std::string _caption): ("no-smt", po::bool_switch(&disableSMT), "disable SMT checker") ("optimize", po::bool_switch(&optimize), "enables optimization") ("enforce-via-yul", po::bool_switch(&enforceViaYul), "Enforce compiling all tests via yul to see if additional tests can be activated.") - ("enforce-gas-cost", po::bool_switch(&enforceGasTest), "Enforce gas cost expectations in semantic tests.") - ("enforce-gas-cost-min-value", po::value(&enforceGasTestMinValue), "Threshold value when enforcing gas cost expectations.") + ("enforce-gas-cost", po::bool_switch(&enforceGasTest), "Enforce checking gas cost in semantic tests.") + ("enforce-gas-cost-min-value", po::value(&enforceGasTestMinValue), "Threshold value to enforce adding gas checks to a test.") ("abiencoderv1", po::bool_switch(&useABIEncoderV1), "enables abi encoder v1") ("show-messages", po::bool_switch(&showMessages), "enables message output") ("show-metadata", po::bool_switch(&showMetadata), "enables metadata output"); @@ -122,12 +122,19 @@ void CommonOptions::validate() const ConfigException, "Invalid test path specified." ); - assertThrow( - !enforceGasTest || evmVersion() == langutil::EVMVersion{}, - ConfigException, - "Gas costs can only be enforced on latest evm version." - ); - + if (enforceGasTest) + { + assertThrow( + evmVersion() == langutil::EVMVersion{}, + ConfigException, + "Gas costs can only be enforced on latest evm version." + ); + assertThrow( + useABIEncoderV1 == false, + ConfigException, + "Gas costs can only be enforced on abi encoder v2." + ); + } } bool CommonOptions::parse(int argc, char const* const* argv) diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 0eaa5b65e..0162cd593 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -76,8 +76,8 @@ int registerTests( solidity::test::CommonOptions::get().evmVersion(), solidity::test::CommonOptions::get().vmPaths, _enforceViaYul, - /* enforceGasCost */ false, - 0 + solidity::test::CommonOptions::get().enforceGasTest, + solidity::test::CommonOptions::get().enforceGasTestMinValue }; if (fs::is_directory(fullpath)) { diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index e138da5fb..17f62498c 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -115,9 +115,9 @@ SemanticTest::SemanticTest( parseExpectations(m_reader.stream()); soltestAssert(!m_tests.empty(), "No tests specified in " + _filename); - if (_evmVersion == EVMVersion{}) + if (m_enforceGasCost) { - m_compiler.setVersionType(CompilerStack::VersionType::Empty); + m_compiler.setMetadataFormat(CompilerStack::MetadataFormat::NoMetadata); m_compiler.setMetadataHash(CompilerStack::MetadataHash::None); } } @@ -342,20 +342,21 @@ bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _comp (_compileViaYul ? "ir"s : "legacy"s) + (m_optimiserSettings == OptimiserSettings::full() ? "Optimized" : ""); - // We don't check gas if evm is not set to default version - // or in case we run abiencoderv1 + // We don't check gas if enforce gas cost is not active + // or test is run with abi encoder v1 only // or gas used less than threshold for enforcing feature // or setting is "ir" and it's not included in expectations if ( - m_evmVersion != EVMVersion{} || - solidity::test::CommonOptions::get().useABIEncoderV1 || + !m_enforceGasCost || ( - (!m_enforceGasCost || setting == "ir" || m_gasUsed < m_enforceGasCostMinValue) && + (setting == "ir" || m_gasUsed < m_enforceGasCostMinValue) && io_test.call().expectations.gasUsed.count(setting) == 0 ) ) return true; + solAssert(!m_runWithABIEncoderV1Only, ""); + io_test.setGasCost(setting, m_gasUsed); return io_test.call().expectations.gasUsed.count(setting) > 0 && From b3202f6b3991905aa12c0dc19c6c28b07f8f46ba Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 12 Feb 2021 12:55:36 +0100 Subject: [PATCH 11/13] Ading CI job to check gas costs. --- .circleci/soltest_all.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/soltest_all.sh b/.circleci/soltest_all.sh index 143af7105..ae9c79683 100755 --- a/.circleci/soltest_all.sh +++ b/.circleci/soltest_all.sh @@ -69,8 +69,10 @@ do # run tests against hera ewasm evmc vm, only if OPTIMIZE == 0 and evm version is byzantium EWASM_ARGS="" [ "${EVM}" = "byzantium" ] && [ "${OPTIMIZE}" = "0" ] && EWASM_ARGS="--ewasm" + ENFORCE_GAS_ARGS="" + [ "${EVM}" = "istanbul" ] && ENFORCE_GAS_ARGS="--enforce-gas-cost" - [[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh" + [[ " $RUN_STEPS " == *" $STEP "* ]] && EVM="$EVM" OPTIMIZE="$OPTIMIZE" SOLTEST_FLAGS="$SOLTEST_FLAGS $ENFORCE_GAS_ARGS $EWASM_ARGS" BOOST_TEST_ARGS="-t !@nooptions" "${REPODIR}/.circleci/soltest.sh" STEP=$((STEP + 1)) done done From 63017bd5109aadc1e0a1aaf66d8fb7690f30642f Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Wed, 10 Mar 2021 13:59:20 +0100 Subject: [PATCH 12/13] Not showing gas used if it is equal to m_gas(in case of out of gas failures). --- test/libsolidity/SemanticTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 17f62498c..0afeaa577 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -349,7 +349,7 @@ bool SemanticTest::checkGasCostExpectation(TestFunctionCall& io_test, bool _comp if ( !m_enforceGasCost || ( - (setting == "ir" || m_gasUsed < m_enforceGasCostMinValue) && + (setting == "ir" || m_gasUsed < m_enforceGasCostMinValue || m_gasUsed >= m_gas) && io_test.call().expectations.gasUsed.count(setting) == 0 ) ) From b73e9f3eef8c9331e93fb2f73d7ae62626c72932 Mon Sep 17 00:00:00 2001 From: Djordje Mijovic Date: Fri, 12 Feb 2021 13:45:15 +0100 Subject: [PATCH 13/13] Update tests. --- .../abiEncoderV1/abi_decode_v2_storage.sol | 3 +++ .../abi_encode_calldata_slice.sol | 8 ++++++- .../struct/struct_storage_ptr.sol | 3 +++ .../abi_encode_calldata_slice.sol | 8 ++++++- .../abiEncoderV2/abi_encode_v2.sol | 3 +++ ...2_in_function_inherited_in_v1_contract.sol | 3 +++ ...ode_v2_in_modifier_used_in_v1_contract.sol | 1 + .../abiEncoderV2/calldata_array.sol | 5 ++++- .../abiEncoderV2/storage_array_encoding.sol | 8 ++++++- .../abi_decode_simple_storage.sol | 3 +++ .../arithmetics/check_var_init.sol | 1 + .../arrays_complex_from_and_to_storage.sol | 3 +++ .../array/byte_array_storage_layout.sol | 7 ++++++ .../array/byte_array_transitional_2.sol | 3 +++ .../array/bytes_length_member.sol | 3 +++ .../copying/array_copy_calldata_storage.sol | 3 +++ .../copying/array_copy_cleanup_uint128.sol | 3 +++ .../copying/array_copy_cleanup_uint40.sol | 3 +++ .../copying/array_copy_clear_storage.sol | 3 +++ .../array_copy_clear_storage_packed.sol | 8 ++++++- .../copying/array_copy_different_packing.sol | 3 +++ .../copying/array_copy_including_array.sol | 6 +++++ .../array/copying/array_copy_nested_array.sol | 3 +++ ...ay_copy_storage_storage_different_base.sol | 3 +++ ..._storage_storage_different_base_nested.sol | 3 +++ ...y_copy_storage_storage_dynamic_dynamic.sol | 3 +++ ...ay_copy_storage_storage_static_dynamic.sol | 1 + ...ray_copy_storage_storage_static_simple.sol | 2 ++ ...ray_copy_storage_storage_static_static.sol | 5 ++++- .../array_copy_storage_storage_struct.sol | 3 +++ .../array_copy_storage_to_memory_nested.sol | 3 +++ .../copying/array_copy_target_leftover.sol | 3 +++ .../copying/array_copy_target_leftover2.sol | 3 +++ .../copying/array_copy_target_simple.sol | 3 +++ .../copying/array_copy_target_simple_2.sol | 3 +++ .../array_nested_calldata_to_storage.sol | 4 ++++ .../array_nested_memory_to_storage.sol | 8 ++++++- .../array_of_struct_calldata_to_storage.sol | 3 ++- .../array_of_struct_memory_to_storage.sol | 3 ++- ..._containing_arrays_calldata_to_storage.sol | 3 ++- ...ts_containing_arrays_memory_to_storage.sol | 1 + .../array_storage_multi_items_per_slot.sol | 5 ++++- .../copying/arrays_from_and_to_storage.sol | 3 +++ .../array/copying/bytes_inside_mappings.sol | 6 +++++ .../copying/bytes_storage_to_storage.sol | 17 ++++++++++++++ .../calldata_array_dynamic_to_storage.sol | 3 +++ .../copy_byte_array_in_struct_to_storage.sol | 4 ++++ .../copying/copy_byte_array_to_storage.sol | 3 +++ .../copying/copy_function_storage_array.sol | 3 +++ ...opy_internal_function_array_to_storage.sol | 4 +++- .../array/copying/copy_removes_bytes_data.sol | 3 +++ .../memory_dyn_2d_bytes_to_storage.sol | 3 +++ .../array/copying/storage_memory_nested.sol | 3 +++ .../copying/storage_memory_nested_bytes.sol | 3 +++ .../storage_memory_nested_from_pointer.sol | 3 +++ .../copying/storage_memory_nested_struct.sol | 3 +++ .../copying/storage_memory_packed_dyn.sol | 3 +++ .../array/create_memory_array.sol | 3 +++ .../array/delete/bytes_delete_element.sol | 3 +++ .../delete/delete_storage_array_packed.sol | 1 + .../array/dynamic_array_cleanup.sol | 3 +++ .../array/dynamic_arrays_in_storage.sol | 3 +++ .../array/dynamic_multi_array_cleanup.sol | 3 +++ .../array/fixed_array_cleanup.sol | 5 ++++- .../array/fixed_arrays_as_return_type.sol | 3 +++ .../array/function_array_cross_calls.sol | 3 +++ .../array/pop/array_pop_array_transition.sol | 3 +++ .../array/pop/array_pop_uint16_transition.sol | 3 +++ .../array/pop/array_pop_uint24_transition.sol | 3 +++ .../array/pop/byte_array_pop_copy_long.sol | 3 +++ .../pop/byte_array_pop_long_storage_empty.sol | 3 +++ ...ray_pop_long_storage_empty_garbage_ref.sol | 3 +++ .../array/pop/byte_array_pop_masking_long.sol | 3 +++ .../semanticTests/array/push/array_push.sol | 3 +++ .../push/array_push_nested_from_calldata.sol | 3 +++ .../array/push/array_push_packed_array.sol | 3 +++ .../array/push/array_push_struct.sol | 3 +++ .../push/array_push_struct_from_calldata.sol | 5 ++++- .../array/push/byte_array_push_transition.sol | 3 +++ .../array/push/push_no_args_2d.sol | 6 +++++ .../array/push/push_no_args_bytes.sol | 3 +++ .../semanticTests/array/reusing_memory.sol | 3 +++ .../constructor/arrays_in_constructors.sol | 3 +++ .../bytes_in_constructors_packer.sol | 3 +++ .../constructor_function_complex.sol | 1 + .../constructor/no_callvalue_check.sol | 3 +++ .../externalContracts/deposit_contract.sol | 18 +++++++++++++-- .../semanticTests/externalContracts/snark.sol | 5 ++++- .../free_namesake_contract_function.sol | 2 +- .../freeFunctions/new_operator.sol | 1 + .../creation_function_call_no_args.sol | 1 + .../functionCall/failed_create.sol | 8 ++++++- .../mapping_array_internal_argument.sol | 3 +++ .../functionTypes/store_function.sol | 3 +++ .../immutable/multi_creation.sol | 3 +++ .../address_overload_resolution.sol | 4 ++++ ...d_function_calldata_calldata_interface.sol | 2 ++ ...ted_function_calldata_memory_interface.sol | 3 +++ .../inheritance/member_notation_ctor.sol | 2 ++ .../interface_inheritance_conversions.sol | 5 +++++ .../reverts/invalid_instruction.sol | 2 +- .../salted_create/salted_create.sol | 5 ++++- .../salted_create_with_value.sol | 5 ++++- .../semanticTests/smoke/alignment.sol | 2 +- .../storage/packed_storage_structs_bytes.sol | 5 ++++- ...ta_struct_with_nested_array_to_storage.sol | 5 ++++- .../conversion/recursive_storage_memory.sol | 1 + .../structs/memory_structs_nested_load.sol | 3 +++ ...truct_containing_bytes_copy_and_delete.sol | 3 +++ .../semanticTests/structs/struct_copy.sol | 6 +++++ .../structs/struct_copy_via_local.sol | 5 ++++- .../struct_delete_storage_nested_small.sol | 1 + .../struct_delete_storage_with_array.sol | 3 +++ ...truct_delete_storage_with_arrays_small.sol | 1 + .../struct_memory_to_storage_function_ptr.sol | 3 +++ .../semanticTests/structs/structs.sol | 3 +++ .../various/code_access_content.sol | 2 ++ .../various/code_access_create.sol | 1 + .../various/code_access_runtime.sol | 1 + .../various/destructuring_assignment.sol | 3 +++ .../various/external_types_in_calls.sol | 1 + .../skip_dynamic_types_for_structs.sol | 3 +++ .../various/staticcall_for_view_and_pure.sol | 9 +++++++- .../various/swap_in_storage_overwrite.sol | 5 ++++- .../viaYul/array_function_pointers.sol | 8 +++---- .../viaYul/array_memory_index_access.sol | 3 +++ .../viaYul/array_storage_index_access.sol | 22 +++++++++++++++++++ .../array_storage_index_boundary_test.sol | 6 +++++ .../array_storage_index_zeroed_test.sol | 12 ++++++++++ .../viaYul/array_storage_length_access.sol | 6 +++++ .../viaYul/array_storage_push_empty.sol | 10 +++++++-- ...rray_storage_push_empty_length_address.sol | 13 +++++++++-- .../viaYul/array_storage_push_pop.sol | 11 +++++++++- 133 files changed, 502 insertions(+), 37 deletions(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol index cdedf048e..89fb4f2d4 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_decode_v2_storage.sol @@ -24,3 +24,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 0x8, 0x40, 0x3, 0x9, 0xa, 0xb +// gas irOptimized: 194189 +// gas legacy: 196426 +// gas legacyOptimized: 193424 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index aaffb5b4b..7af329fec 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -56,8 +56,14 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >homestead +// compileViaYul: also // ---- // test_bytes() -> +// gas irOptimized: 516922 +// gas legacy: 466763 +// gas legacyOptimized: 374537 // test_uint256() -> +// gas irOptimized: 712790 +// gas legacy: 634592 +// gas legacyOptimized: 499481 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index 8ffd75153..116501486 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -26,3 +26,6 @@ contract C { // ---- // library: L // f() -> 8, 7, 1, 2, 7, 12 +// gas irOptimized: 172153 +// gas legacy: 164775 +// gas legacyOptimized: 162697 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 9e5985cbc..139dc6419 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -57,8 +57,14 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >homestead +// compileViaYul: also // ---- // test_bytes() -> +// gas irOptimized: 516922 +// gas legacy: 466763 +// gas legacyOptimized: 374537 // test_uint256() -> +// gas irOptimized: 712790 +// gas legacy: 634592 +// gas legacyOptimized: 499481 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol index 8fb565d3f..600aced74 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol @@ -53,3 +53,6 @@ contract C { // f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc" // f4() -> 0x20, 0x160, 0x1, 0x80, 0xc0, 0x2, 0x3, "abc", 0x7, 0x40, 0x2, 0x2, 0x3 +// gas irOptimized: 110858 +// gas legacy: 111328 +// gas legacyOptimized: 109206 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol index 8c3341189..e94601c57 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_function_inherited_in_v1_contract.sol @@ -30,3 +30,6 @@ contract C is B { // compileViaYul: also // ---- // test() -> 77 +// gas irOptimized: 139834 +// gas legacy: 156573 +// gas legacyOptimized: 112983 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol index 60d20a781..fa8f9c337 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2_in_modifier_used_in_v1_contract.sol @@ -38,3 +38,4 @@ contract C is B { // compileViaYul: also // ---- // test() -> 5, 10 +// gas legacy: 100441 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index d8bcd4601..8bd584d6c 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -15,9 +15,12 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >homestead +// compileViaYul: also // ---- // f(uint256[][1]): 32, 32, 0 -> true // f(uint256[][1]): 32, 32, 1, 42 -> true // f(uint256[][1]): 32, 32, 8, 421, 422, 423, 424, 425, 426, 427, 428 -> true +// gas irOptimized: 227663 +// gas legacy: 144300 +// gas legacyOptimized: 124199 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol index 1a233681f..878e6831e 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol @@ -15,8 +15,14 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >homestead +// compileViaYul: also // ---- // h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324 +// gas irOptimized: 172714 +// gas legacy: 175929 +// gas legacyOptimized: 172506 // i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224 +// gas irOptimized: 107681 +// gas legacy: 109868 +// gas legacyOptimized: 107388 diff --git a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol index 119c33aeb..e416ab753 100644 --- a/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol +++ b/test/libsolidity/semanticTests/abiencodedecode/abi_decode_simple_storage.sol @@ -11,3 +11,6 @@ contract C { // compileViaYul: also // ---- // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" +// gas irOptimized: 130305 +// gas legacy: 131690 +// gas legacyOptimized: 130574 diff --git a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol index 96edd308a..4587cc71a 100644 --- a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol +++ b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol @@ -18,3 +18,4 @@ contract D { // ---- // f() -> FAILURE, hex"4e487b71", 0x11 // g(), 100 wei -> 1 +// gas legacy: 101718 diff --git a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol index 78d60913d..c88fa43e2 100644 --- a/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/arrays_complex_from_and_to_storage.sol @@ -14,6 +14,9 @@ contract Test { // compileViaYul: also // ---- // set(uint24[3][]): 0x20, 0x06, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12 -> 0x06 +// gas irOptimized: 200205 +// gas legacy: 278685 +// gas legacyOptimized: 273734 // data(uint256,uint256): 0x02, 0x02 -> 0x09 // data(uint256,uint256): 0x05, 0x01 -> 0x11 // data(uint256,uint256): 0x06, 0x00 -> FAILURE diff --git a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol index 588b954ae..c14e4479a 100644 --- a/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol +++ b/test/libsolidity/semanticTests/array/byte_array_storage_layout.sol @@ -43,8 +43,15 @@ contract c { // ---- // storage: empty // test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710 +// gas legacy: 110938 +// gas legacyOptimized: 109691 // storage: nonempty // test_long() -> 67 +// gas irOptimized: 134832 +// gas legacy: 213590 +// gas legacyOptimized: 211011 // storage: nonempty // test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020 +// gas legacy: 176030 +// gas legacyOptimized: 173470 // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol index 46ed1f728..e568b796f 100644 --- a/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol +++ b/test/libsolidity/semanticTests/array/byte_array_transitional_2.sol @@ -19,3 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0 +// gas irOptimized: 312920 +// gas legacy: 483915 +// gas legacyOptimized: 478508 diff --git a/test/libsolidity/semanticTests/array/bytes_length_member.sol b/test/libsolidity/semanticTests/array/bytes_length_member.sol index fbff51f02..9fa5c6507 100644 --- a/test/libsolidity/semanticTests/array/bytes_length_member.sol +++ b/test/libsolidity/semanticTests/array/bytes_length_member.sol @@ -15,4 +15,7 @@ contract c { // ---- // getLength() -> 0 // set(): 1, 2 -> true +// gas irOptimized: 103213 +// gas legacy: 103126 +// gas legacyOptimized: 102966 // getLength() -> 68 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol index 20c934bc4..60c021672 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_calldata_storage.sol @@ -22,4 +22,7 @@ contract c { // compileViaYul: also // ---- // store(uint256[9],uint8[3][]): 21, 22, 23, 24, 25, 26, 27, 28, 29, 0x140, 4, 1, 2, 3, 11, 12, 13, 21, 22, 23, 31, 32, 33 -> 32 +// gas irOptimized: 629040 +// gas legacy: 817315 +// gas legacyOptimized: 816813 // retrieve() -> 9, 28, 9, 28, 4, 3, 32 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol index 5cfe4865c..b27bcdf6d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint128.sol @@ -23,3 +23,6 @@ contract C { // compileViaYul: also // ---- // f() -> true +// gas irOptimized: 112029 +// gas legacy: 107335 +// gas legacyOptimized: 105857 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol index 37d78e6ab..c296d9cfa 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_cleanup_uint40.sol @@ -48,3 +48,6 @@ contract C { // compileViaYul: also // ---- // f() -> true +// gas irOptimized: 253583 +// gas legacy: 239061 +// gas legacyOptimized: 235988 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol index 98339880b..1079873f3 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage.sol @@ -15,3 +15,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0 +// gas irOptimized: 150551 +// gas legacy: 138913 +// gas legacyOptimized: 137448 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol index 2118a854d..de203891d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_clear_storage_packed.sol @@ -42,5 +42,11 @@ contract C { // compileViaYul: also // ---- // f() -> 0 +// gas irOptimized: 112032 +// gas legacy: 107306 +// gas legacyOptimized: 105861 // g() -> 0 -// h() -> 0 \ No newline at end of file +// h() -> 0 +// gas irOptimized: 112057 +// gas legacy: 107328 +// gas legacyOptimized: 105903 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol index 7e3bf79dc..b157b0823 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_different_packing.sol @@ -21,3 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x05000000000000000000000000000000000000000000000000 +// gas irOptimized: 247582 +// gas legacy: 276683 +// gas legacyOptimized: 275534 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol index a600bffdd..181104a09 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol @@ -37,6 +37,12 @@ contract c { // compileViaYul: also // ---- // test() -> 0x02000202 +// gas irOptimized: 2481131 +// gas legacy: 2288641 +// gas legacyOptimized: 2258654 // storage: empty // clear() -> 0, 0 +// gas irOptimized: 1856788 +// gas legacy: 1727169 +// gas legacyOptimized: 1698931 // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index bd4b1ea92..b25fa2663 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -15,3 +15,6 @@ contract c { // compileViaYul: also // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 +// gas irOptimized: 611500 +// gas legacy: 604268 +// gas legacyOptimized: 603690 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol index fa35e8aeb..26de595a9 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base.sol @@ -19,3 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4 +// gas irOptimized: 235646 +// gas legacy: 237001 +// gas legacyOptimized: 235316 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol index 35536c8d3..1eddf943e 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_different_base_nested.sol @@ -23,3 +23,6 @@ contract c { // compileViaYul: also // ---- // test() -> 3, 4 +// gas irOptimized: 195485 +// gas legacy: 208853 +// gas legacyOptimized: 200341 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol index 7815f0a28..26ee19f44 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dynamic_dynamic.sol @@ -20,3 +20,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4 +// gas irOptimized: 276032 +// gas legacy: 264734 +// gas legacyOptimized: 263160 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol index 9b3ba326e..ce95fad9e 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_dynamic.sol @@ -14,3 +14,4 @@ contract c { // compileViaYul: also // ---- // test() -> 9, 4 +// gas irOptimized: 100285 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol index 90e117ae1..25e057936 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_simple.sol @@ -13,3 +13,5 @@ contract C { // compileViaYul: also // ---- // test() -> left(0x01), left(0x02) +// gas legacy: 154001 +// gas legacyOptimized: 152385 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol index 207777edb..4c04ce509 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_static_static.sol @@ -14,7 +14,10 @@ contract c { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // test() -> 8, 0 +// gas irOptimized: 158935 +// gas legacy: 153995 +// gas legacyOptimized: 153403 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index 097c86dfe..1d698d7d4 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -19,4 +19,7 @@ contract c { // compileViaYul: also // ---- // test() -> 4, 5 +// gas irOptimized: 282888 +// gas legacy: 255936 +// gas legacyOptimized: 254359 // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol index 0fb56593c..0948ea08d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory_nested.sol @@ -17,3 +17,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 2, 0x40, 0xa0, 2, 0, 1, 2, 2, 3 +// gas irOptimized: 170704 +// gas legacy: 163978 +// gas legacyOptimized: 158152 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol index a9c2dcca0..5ac23d731 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol @@ -19,3 +19,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000 +// gas irOptimized: 223456 +// gas legacy: 328106 +// gas legacyOptimized: 308072 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol index fa35ec888..e3be4ed5d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover2.sol @@ -21,3 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x04000000000000000000000000000000000000000000000000, 0x0, 0x0 +// gas irOptimized: 109240 +// gas legacy: 116651 +// gas legacyOptimized: 107000 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol index 5f854c724..1815870f3 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple.sol @@ -21,3 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x0 +// gas irOptimized: 290262 +// gas legacy: 309353 +// gas legacyOptimized: 307699 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol index f2358c718..16dc5bbd6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_simple_2.sol @@ -21,3 +21,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x01000000000000000000000000000000000000000000000000, 0x02000000000000000000000000000000000000000000000000, 0x03000000000000000000000000000000000000000000000000, 0x04000000000000000000000000000000000000000000000000, 0x00 +// gas irOptimized: 269636 +// gas legacy: 269681 +// gas legacyOptimized: 268753 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index efd90f88f..7363793be 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -38,6 +38,10 @@ contract c { // compileViaYul: true // ---- // test1(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 23, 42 -> 2, 65 +// gas irOptimized: 179776 // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 +// gas irOptimized: 155253 // test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 +// gas irOptimized: 133521 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 +// gas irOptimized: 107882 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol index 45714648b..104bc0050 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_memory_to_storage.sol @@ -40,6 +40,12 @@ contract Test { // compileViaYul: also // ---- // test() -> 24 +// gas irOptimized: 217774 +// gas legacy: 215533 +// gas legacyOptimized: 214947 // test1() -> 3 // test2() -> 6 -// test3() -> 24 \ No newline at end of file +// test3() -> 24 +// gas irOptimized: 124684 +// gas legacy: 122795 +// gas legacyOptimized: 121883 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol index f8350c67e..777013bbf 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol @@ -16,4 +16,5 @@ contract C { // ==== // compileViaYul: true // ---- -// f((uint128, uint64, uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 \ No newline at end of file +// f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 +// gas irOptimized: 123327 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol index 73fde3aba..42bbe7f95 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol @@ -18,4 +18,5 @@ contract C { // ==== // compileViaYul: true // ---- -// f() -> 10, 11, 12 \ No newline at end of file +// f() -> 10, 11, 12 +// gas irOptimized: 122695 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol index e930a8ea6..c6434502e 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol @@ -22,4 +22,5 @@ contract C { // ==== // compileViaYul: true // ---- -// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 \ No newline at end of file +// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1 +// gas irOptimized: 354585 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol index 5d332e6e8..3874d3a59 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol @@ -26,3 +26,4 @@ contract C { // compileViaYul: true // ---- // f() -> 3, 3, 3, 1 +// gas irOptimized: 189829 diff --git a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol index 1a0435452..26cd4cb15 100644 --- a/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol +++ b/test/libsolidity/semanticTests/array/copying/array_storage_multi_items_per_slot.sol @@ -11,7 +11,10 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // f() -> 1, 2, 3 +// gas irOptimized: 135092 +// gas legacy: 134419 +// gas legacyOptimized: 125440 diff --git a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol index 8b99bf14c..30b2fed23 100644 --- a/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/arrays_from_and_to_storage.sol @@ -12,6 +12,9 @@ contract Test { // compileViaYul: also // ---- // set(uint24[]): 0x20, 18, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 -> 18 +// gas irOptimized: 121147 +// gas legacy: 125815 +// gas legacyOptimized: 123617 // data(uint256): 7 -> 8 // data(uint256): 15 -> 16 // data(uint256): 18 -> FAILURE diff --git a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol index 2decb1562..c8ab2717f 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_inside_mappings.sol @@ -7,7 +7,13 @@ contract c { // compileViaYul: also // ---- // set(uint256): 1, 2 -> true +// gas irOptimized: 103365 +// gas legacy: 103491 +// gas legacyOptimized: 103135 // set(uint256): 2, 2, 3, 4, 5 -> true +// gas irOptimized: 164052 +// gas legacy: 164121 +// gas legacyOptimized: 163765 // storage: nonempty // copy(uint256,uint256): 1, 2 -> true // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol index 8db478736..b0b4d9221 100644 --- a/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/bytes_storage_to_storage.sol @@ -19,8 +19,25 @@ contract c { // ---- // f(uint256): 0 -> 0x20, 0x00 // f(uint256): 31 -> 0x20, 0x1f, 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e00 +// gas irOptimized: 222684 +// gas legacy: 255464 +// gas legacyOptimized: 250931 // f(uint256): 32 -> 0x20, 0x20, 1780731860627700044960722568376592200742329637303199754547598369979440671 +// gas irOptimized: 233443 +// gas legacy: 267931 +// gas legacyOptimized: 263260 // f(uint256): 33 -> 0x20, 33, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x2000000000000000000000000000000000000000000000000000000000000000 +// gas irOptimized: 242278 +// gas legacy: 277538 +// gas legacyOptimized: 272747 // f(uint256): 63 -> 0x20, 0x3f, 1780731860627700044960722568376592200742329637303199754547598369979440671, 14532552714582660066924456880521368950258152170031413196862950297402215316992 +// gas irOptimized: 356428 +// gas legacy: 423428 +// gas legacyOptimized: 414737 // f(uint256): 12 -> 0x20, 0x0c, 0x0102030405060708090a0b0000000000000000000000000000000000000000 +// gas legacy: 106445 +// gas legacyOptimized: 104350 // f(uint256): 129 -> 0x20, 0x81, 1780731860627700044960722568376592200742329637303199754547598369979440671, 0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f, 29063324697304692433803953038474361308315562010425523193971352996434451193439, 0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f, -57896044618658097711785492504343953926634992332820282019728792003956564819968 +// gas irOptimized: 817738 +// gas legacy: 954517 +// gas legacyOptimized: 937258 diff --git a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol index 9c1022298..46272de63 100644 --- a/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/calldata_array_dynamic_to_storage.sol @@ -11,3 +11,6 @@ contract C { // compileViaYul: also // ---- // f(uint256[]): 0x20, 0x03, 0x1, 0x2, 0x3 -> 0x1 +// gas irOptimized: 108100 +// gas legacy: 105365 +// gas legacyOptimized: 105149 diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol index f318ee099..ca312ff45 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_in_struct_to_storage.sol @@ -37,6 +37,10 @@ contract C { // compileViaYul: also // ---- // f() -> 0x40, 0x80, 6, 0x6162636465660000000000000000000000000000000000000000000000000000, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000 +// gas irOptimized: 172892 +// gas legacy: 174794 +// gas legacyOptimized: 174182 // g() -> 0x40, 0xc0, 0x49, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738393031323334353637383930313233343536373839303120, 0x3132333435363738390000000000000000000000000000000000000000000000, 0x11, 0x3132333435363738393233343536373839000000000000000000000000000000 +// gas legacy: 100595 // h() -> 0x40, 0x60, 0x00, 0x00 // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol index de36b0a29..ff7c1995f 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_byte_array_to_storage.sol @@ -48,3 +48,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0xff +// gas irOptimized: 137428 +// gas legacy: 137645 +// gas legacyOptimized: 134372 diff --git a/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol b/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol index 7b3022361..6be752f81 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_function_storage_array.sol @@ -18,3 +18,6 @@ contract C { // compileViaYul: also // ---- // test() -> 7 +// gas irOptimized: 134482 +// gas legacy: 211296 +// gas legacyOptimized: 211087 diff --git a/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol index f98bcb40d..83140f3d4 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_internal_function_array_to_storage.sol @@ -18,8 +18,10 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // one() -> 3 +// gas legacy: 154760 +// gas legacyOptimized: 154597 // two() -> FAILURE, hex"4e487b71", 0x51 diff --git a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol index ace34e872..17be94e13 100644 --- a/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol +++ b/test/libsolidity/semanticTests/array/copying/copy_removes_bytes_data.sol @@ -9,6 +9,9 @@ contract c { // compileViaYul: also // ---- // set(): 1, 2, 3, 4, 5 -> true +// gas irOptimized: 163861 +// gas legacy: 163756 +// gas legacyOptimized: 163595 // storage: nonempty // reset() -> true // storage: empty diff --git a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol index 1b22b4d85..74818674c 100644 --- a/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/memory_dyn_2d_bytes_to_storage.sol @@ -20,3 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> 3 +// gas irOptimized: 175292 +// gas legacy: 179707 +// gas legacyOptimized: 178734 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol index 59f5ecffe..fc37494c9 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested.sol @@ -19,3 +19,6 @@ contract C { // compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 +// gas irOptimized: 218149 +// gas legacy: 223725 +// gas legacyOptimized: 222886 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol index 7ce90c5f2..9ba9efc36 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_bytes.sol @@ -13,3 +13,6 @@ contract C { // compileViaYul: also // ---- // f() -> 0x20, 0x02, 0x40, 0x80, 3, 0x6162630000000000000000000000000000000000000000000000000000000000, 0x99, 44048183304486788312148433451363384677562265908331949128489393215789685032262, 32241931068525137014058842823026578386641954854143559838526554899205067598957, 49951309422467613961193228765530489307475214998374779756599339590522149884499, 0x54555658595a6162636465666768696a6b6c6d6e6f707172737475767778797a, 0x4142434445464748494a4b4c4d4e4f5051525354555658595a00000000000000 +// gas irOptimized: 198780 +// gas legacy: 199159 +// gas legacyOptimized: 198128 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol index 6a687bdcf..13f2be4e9 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_from_pointer.sol @@ -20,3 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> 1, 2, 3, 4, 5, 6, 7 +// gas irOptimized: 218149 +// gas legacy: 223730 +// gas legacyOptimized: 222891 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol index d59f236de..22c6fdbab 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_nested_struct.sol @@ -26,3 +26,6 @@ contract C { // compileViaYul: also // ---- // f() -> 11, 0x0c, 1, 0x15, 22, 4 +// gas irOptimized: 292660 +// gas legacy: 296916 +// gas legacyOptimized: 283163 diff --git a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol index d4ef03fbd..3b576388e 100644 --- a/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/storage_memory_packed_dyn.sol @@ -15,3 +15,6 @@ contract C { // compileViaYul: also // ---- // f() -> 2, 3, 4 +// gas irOptimized: 240441 +// gas legacy: 241549 +// gas legacyOptimized: 236002 diff --git a/test/libsolidity/semanticTests/array/create_memory_array.sol b/test/libsolidity/semanticTests/array/create_memory_array.sol index cf00ccaa6..34f58b4bc 100644 --- a/test/libsolidity/semanticTests/array/create_memory_array.sol +++ b/test/libsolidity/semanticTests/array/create_memory_array.sol @@ -20,3 +20,6 @@ contract C { // compileViaYul: also // ---- // f() -> "A", 8, 4, "B" +// gas irOptimized: 170583 +// gas legacy: 121398 +// gas legacyOptimized: 115494 diff --git a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol index 6cf0da3bb..63f41d7cc 100644 --- a/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol +++ b/test/libsolidity/semanticTests/array/delete/bytes_delete_element.sol @@ -18,3 +18,6 @@ contract c { // compileViaYul: also // ---- // test1() -> true +// gas irOptimized: 534222 +// gas legacy: 613377 +// gas legacyOptimized: 606202 diff --git a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol index 281c9a0e5..6e38b0c95 100644 --- a/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol +++ b/test/libsolidity/semanticTests/array/delete/delete_storage_array_packed.sol @@ -16,3 +16,4 @@ contract C { // compileViaYul: also // ---- // f() -> 0, 0, 0 +// gas irOptimized: 101935 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index 07c3f63aa..0fb61f5d3 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -16,6 +16,9 @@ contract c { // ---- // storage: empty // fill() -> +// gas irOptimized: 536238 +// gas legacy: 504373 +// gas legacyOptimized: 499648 // storage: nonempty // halfClear() -> // storage: nonempty diff --git a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol index 16f6ba1a6..b1e075421 100644 --- a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol @@ -44,6 +44,9 @@ contract c { // ---- // getLengths() -> 0, 0 // setLengths(uint256,uint256): 48, 49 -> +// gas irOptimized: 276446 +// gas legacy: 308271 +// gas legacyOptimized: 300117 // getLengths() -> 48, 49 // setIDStatic(uint256): 11 -> // getID(uint256): 2 -> 11 diff --git a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol index c58abad52..694e13f78 100644 --- a/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_multi_array_cleanup.sol @@ -18,6 +18,9 @@ contract c { // ---- // storage: empty // fill() -> 8 +// gas irOptimized: 181164 +// gas legacy: 165456 +// gas legacyOptimized: 164387 // storage: nonempty // clear() -> // storage: empty diff --git a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol index 074173e9a..b87d65e6e 100644 --- a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol @@ -8,11 +8,14 @@ contract c { function clear() public { delete data; } } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // storage: empty // fill() -> +// gas irOptimized: 423997 +// gas legacy: 429460 +// gas legacyOptimized: 425520 // storage: nonempty // clear() -> // storage: empty diff --git a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol index c09d397ee..738260026 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -21,3 +21,6 @@ contract B { // compileViaYul: also // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 +// gas irOptimized: 179491 +// gas legacy: 264410 +// gas legacyOptimized: 134899 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index d81240069..ba045d5cc 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -45,3 +45,6 @@ contract C { // compileViaYul: also // ---- // test() -> 5, 6, 7 +// gas irOptimized: 360048 +// gas legacy: 500424 +// gas legacyOptimized: 307615 diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol index ece182803..f1ee80776 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_array_transition.sol @@ -25,4 +25,7 @@ contract c { // compileViaYul: also // ---- // test() -> 1, 2, 3 +// gas irOptimized: 2556862 +// gas legacy: 2416722 +// gas legacyOptimized: 2405396 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol index 8cecac615..649689ac9 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint16_transition.sol @@ -20,4 +20,7 @@ contract c { // compileViaYul: also // ---- // test() -> 38, 28, 18 +// gas irOptimized: 539280 +// gas legacy: 454080 +// gas legacyOptimized: 443170 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol index 467774cc2..4f707555d 100644 --- a/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol +++ b/test/libsolidity/semanticTests/array/pop/array_pop_uint24_transition.sol @@ -20,4 +20,7 @@ contract c { // compileViaYul: also // ---- // test() -> 20, 10 +// gas irOptimized: 374378 +// gas legacy: 320859 +// gas legacyOptimized: 314681 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol index 49950aedc..f62218a3c 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_copy_long.sol @@ -12,3 +12,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x20, 29, 0x0303030303030303030303030303030303030303030303030303030303000000 +// gas irOptimized: 163882 +// gas legacy: 245809 +// gas legacyOptimized: 242597 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol index b4d0adfc0..e6b33a734 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty.sol @@ -18,4 +18,7 @@ contract c { // compileViaYul: also // ---- // test() -> true +// gas irOptimized: 461007 +// gas legacy: 552064 +// gas legacyOptimized: 533000 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index a230eb033..57d58ef26 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -17,4 +17,7 @@ contract c { // compileViaYul: also // ---- // test() -> +// gas irOptimized: 302445 +// gas legacy: 372763 +// gas legacyOptimized: 366764 // storage: empty diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol index 1d4657073..f7feb7ee9 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_masking_long.sol @@ -12,3 +12,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0x20, 33, 0x303030303030303030303030303030303030303030303030303030303030303, 0x0300000000000000000000000000000000000000000000000000000000000000 +// gas irOptimized: 161233 +// gas legacy: 243287 +// gas legacyOptimized: 240324 diff --git a/test/libsolidity/semanticTests/array/push/array_push.sol b/test/libsolidity/semanticTests/array/push/array_push.sol index 5923580fa..eab685539 100644 --- a/test/libsolidity/semanticTests/array/push/array_push.sol +++ b/test/libsolidity/semanticTests/array/push/array_push.sol @@ -18,3 +18,6 @@ contract c { // compileViaYul: also // ---- // test() -> 5, 4, 3, 3 +// gas irOptimized: 116397 +// gas legacy: 111938 +// gas legacyOptimized: 110528 diff --git a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol index 66df10a6e..9f8035d33 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_nested_from_calldata.sol @@ -14,3 +14,6 @@ contract C { // compileViaYul: also // ---- // f(uint120[]): 0x20, 3, 1, 2, 3 -> 1 +// gas irOptimized: 116603 +// gas legacy: 116886 +// gas legacyOptimized: 116701 diff --git a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol index e99221671..280deaed1 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_packed_array.sol @@ -16,3 +16,6 @@ contract c { // compileViaYul: also // ---- // test() -> 1, 2, 3, 4 +// gas irOptimized: 112771 +// gas legacy: 107098 +// gas legacyOptimized: 106362 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct.sol b/test/libsolidity/semanticTests/array/push/array_push_struct.sol index 38e6957b7..80af61a29 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct.sol @@ -22,3 +22,6 @@ contract c { // compileViaYul: also // ---- // test() -> 2, 3, 4, 5 +// gas irOptimized: 147411 +// gas legacy: 190684 +// gas legacyOptimized: 188256 diff --git a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol index 11ac40f0e..d504d079d 100644 --- a/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol +++ b/test/libsolidity/semanticTests/array/push/array_push_struct_from_calldata.sol @@ -17,4 +17,7 @@ contract c { // ==== // compileViaYul: also // ---- -// test((uint16, uint16, uint16[3], uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5 +// test((uint16,uint16,uint16[3],uint16[])): 0x20, 2, 3, 0, 0, 4, 0xC0, 4, 0, 0, 5, 0, 0 -> 2, 3, 4, 5 +// gas irOptimized: 148672 +// gas legacy: 152444 +// gas legacyOptimized: 146666 diff --git a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol index f0733a7f5..aa08bd513 100644 --- a/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol +++ b/test/libsolidity/semanticTests/array/push/byte_array_push_transition.sol @@ -17,3 +17,6 @@ contract c { // compileViaYul: also // ---- // test() -> 0 +// gas irOptimized: 398636 +// gas legacy: 565428 +// gas legacyOptimized: 552330 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol index ce2b6f668..6a26db287 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -29,10 +29,16 @@ contract C { // ---- // l() -> 0 // f(uint256,uint256): 42, 64 -> +// gas irOptimized: 202798 +// gas legacy: 163034 +// gas legacyOptimized: 157045 // l() -> 1 // ll(uint256): 0 -> 43 // a(uint256,uint256): 0, 42 -> 64 // f(uint256,uint256): 84, 128 -> +// gas irOptimized: 299014 +// gas legacy: 222080 +// gas legacyOptimized: 210631 // l() -> 2 // ll(uint256): 1 -> 85 // a(uint256,uint256): 0, 42 -> 64 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol index 45bd4bfec..f73953add 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol @@ -23,6 +23,9 @@ contract C { // ---- // l() -> 0 // g(uint256): 70 -> +// gas irOptimized: 433788 +// gas legacy: 419791 +// gas legacyOptimized: 415338 // l() -> 70 // a(uint256): 69 -> left(69) // f() -> diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 32f21b675..3436065d3 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -26,3 +26,6 @@ contract Main { // compileViaYul: also // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 +// gas irOptimized: 117287 +// gas legacy: 127152 +// gas legacyOptimized: 113679 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index ae380af8e..33e372e01 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -26,3 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 +// gas irOptimized: 472538 +// gas legacy: 570900 +// gas legacyOptimized: 436164 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index 1a9832e88..2cfee3ab0 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -26,3 +26,6 @@ contract Creator { // compileViaYul: also // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" +// gas irOptimized: 335246 +// gas legacy: 414850 +// gas legacyOptimized: 290276 diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol index 1fbb16c2a..459a5a239 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol @@ -19,3 +19,4 @@ contract C { // compileViaYul: also // ---- // f() -> 16 +// gas legacy: 104744 diff --git a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol index 0da5f49b7..4efebba23 100644 --- a/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol +++ b/test/libsolidity/semanticTests/constructor/no_callvalue_check.sol @@ -19,3 +19,6 @@ contract C { // compileViaYul: also // ---- // f(), 2000 ether -> true +// gas irOptimized: 123853 +// gas legacy: 123226 +// gas legacyOptimized: 123092 diff --git a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol index 6f380ebee..3f19a8629 100644 --- a/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol +++ b/test/libsolidity/semanticTests/externalContracts/deposit_contract.sol @@ -178,19 +178,33 @@ contract DepositContract is IDepositContract, ERC165 { // compileViaYul: also // ---- // constructor() +// gas irOptimized: 1813459 +// gas legacy: 2558004 +// gas legacyOptimized: 1806764 // supportsInterface(bytes4): 0x0 -> 0 // supportsInterface(bytes4): 0xffffffff00000000000000000000000000000000000000000000000000000000 -> false # defined to be false by ERC-165 # // supportsInterface(bytes4): 0x01ffc9a700000000000000000000000000000000000000000000000000000000 -> true # ERC-165 id # // supportsInterface(bytes4): 0x8564090700000000000000000000000000000000000000000000000000000000 -> true # the deposit interface id # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e -// get_deposit_count() -> 0x20, 8, 0 -// # TODO: check balance and logs after each deposit # +// gas irOptimized: 107589 +// gas legacy: 128065 +// gas legacyOptimized: 100398 +// get_deposit_count() -> 0x20, 8, 0 # TODO: check balance and logs after each deposit # // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0 -> FAILURE # Empty input # // get_deposit_root() -> 0xd70a234731285c6804c2a4f56711ddb8c82c99740f207854891028af34e27e5e +// gas irOptimized: 107589 +// gas legacy: 128065 +// gas legacyOptimized: 100398 // get_deposit_count() -> 0x20, 8, 0 // deposit(bytes,bytes,bytes,bytes32), 1 ether: 0x80, 0xe0, 0x120, 0xaa4a8d0b7d9077248630f1a4701ae9764e42271d7f22b7838778411857fd349e, 0x30, 0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f73292, 0x67a8811c397529dac52ae1342ba58c9500000000000000000000000000000000, 0x20, 0x00f50428677c60f997aadeab24aabf7fceaef491c96a52b463ae91f95611cf71, 0x60, 0xa29d01cc8c6296a8150e515b5995390ef841dc18948aa3e79be6d7c1851b4cbb, 0x5d6ff49fa70b9c782399506a22a85193151b9b691245cebafd2063012443c132, 0x4b6c36debaedefb7b2d71b0503ffdc00150aaffd42e63358238ec888901738b8 -> # txhash: 0x7085c586686d666e8bb6e9477a0f0b09565b2060a11f1c4209d3a52295033832 # // get_deposit_root() -> 0x2089653123d9c721215120b6db6738ba273bbc5228ac093b1f983badcdc8a438 +// gas irOptimized: 107599 +// gas legacy: 128075 +// gas legacyOptimized: 100411 // get_deposit_count() -> 0x20, 8, 0x0100000000000000000000000000000000000000000000000000000000000000 // deposit(bytes,bytes,bytes,bytes32), 32 ether: 0x80, 0xe0, 0x120, 0xdbd986dc85ceb382708cf90a3500f500f0a393c5ece76963ac3ed72eccd2c301, 0x30, 0xb2ce0f79f90e7b3a113ca5783c65756f96c4b4673c2b5c1eb4efc22280259441, 0x06d601211e8866dc5b50dc48a244dd7c00000000000000000000000000000000, 0x20, 0x00344b6c73f71b11c56aba0d01b7d8ad83559f209d0a4101a515f6ad54c89771, 0x60, 0x945caaf82d18e78c033927d51f452ebcd76524497b91d7a11219cb3db6a1d369, 0x7595fc095ce489e46b2ef129591f2f6d079be4faaf345a02c5eb133c072e7c56, 0x0c6c3617eee66b4b878165c502357d49485326bc6b31bc96873f308c8f19c09d -> # txhash: 0x404d8e109822ce448e68f45216c12cb051b784d068fbe98317ab8e50c58304ac # // get_deposit_root() -> 0x40255975859377d912c53aa853245ebd939bdd2b33a28e084babdcc1ed8238ee +// gas irOptimized: 107599 +// gas legacy: 128075 +// gas legacyOptimized: 100411 // get_deposit_count() -> 0x20, 8, 0x0200000000000000000000000000000000000000000000000000000000000000 diff --git a/test/libsolidity/semanticTests/externalContracts/snark.sol b/test/libsolidity/semanticTests/externalContracts/snark.sol index 4ab6a61fc..8f7722849 100644 --- a/test/libsolidity/semanticTests/externalContracts/snark.sol +++ b/test/libsolidity/semanticTests/externalContracts/snark.sol @@ -288,11 +288,14 @@ contract Test { /// testMul() -> true // // ==== -// compileViaYul: also // EVMVersion: >=constantinople +// compileViaYul: also // ---- // library: Pairing // f() -> true // g() -> true // pair() -> true // verifyTx() -> true +// gas irOptimized: 146496 +// gas legacy: 130571 +// gas legacyOptimized: 100187 diff --git a/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol b/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol index 88cd5f4d0..9c88bb49f 100644 --- a/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol +++ b/test/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol @@ -5,7 +5,7 @@ contract C { } } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // f() -> FAILURE diff --git a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol index d0eea9f96..eae09bb52 100644 --- a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol +++ b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol @@ -15,3 +15,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 +// gas legacy: 101554 diff --git a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol index f60827738..953625d99 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol @@ -13,3 +13,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 +// gas legacy: 101527 diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index 6a567293c..8d5017749 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -14,15 +14,21 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >=byzantium +// compileViaYul: also // ---- // constructor(), 20 wei +// gas irOptimized: 232551 +// gas legacy: 285485 +// gas legacyOptimized: 177957 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 // x() -> 1 // f(uint256): 20 -> FAILURE // x() -> 1 // stack(uint256): 1023 -> FAILURE +// gas irOptimized: 835314 +// gas legacy: 981671 +// gas legacyOptimized: 824895 // x() -> 1 // stack(uint256): 10 -> 693016686122178122849713379390321835634789309880 // x() -> 2 diff --git a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol index 4fcc640f6..899025ae6 100644 --- a/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol +++ b/test/libsolidity/semanticTests/functionCall/mapping_array_internal_argument.sol @@ -20,6 +20,9 @@ contract test { // compileViaYul: also // ---- // set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0 +// gas irOptimized: 110993 +// gas legacy: 111406 +// gas legacyOptimized: 107981 // get(uint8): 1 -> 21, 22, 42, 43 // set(uint8,uint8,uint8,uint8,uint8): 1, 10, 30, 11, 31 -> 21, 22, 42, 43 // get(uint8): 1 -> 10, 30, 11, 31 diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index d7b285802..60ec452c4 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -28,3 +28,6 @@ contract C { // compileViaYul: also // ---- // t() -> 9 +// gas irOptimized: 124896 +// gas legacy: 161097 +// gas legacyOptimized: 111516 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index 33820b18b..2186dedbe 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -29,5 +29,8 @@ contract C { // compileViaYul: also // ---- // f() -> 3, 7, 5 +// gas irOptimized: 133517 +// gas legacy: 153990 +// gas legacyOptimized: 127822 // x() -> 7 // y() -> 5 diff --git a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol index 640fcce09..23e4b624d 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -23,4 +23,8 @@ contract D { // compileViaYul: also // ---- // f() -> 1 +// gas irOptimized: 111246 +// gas legacy: 114412 // g() -> 5 +// gas irOptimized: 111379 +// gas legacy: 114872 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol index cb89901a4..40a8b5f15 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -25,3 +25,5 @@ contract B { // compileViaYul: also // ---- // g() -> 42 +// gas irOptimized: 107179 +// gas legacy: 117797 diff --git a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol index febaf9f04..d121f1c20 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -25,3 +25,6 @@ contract B { // compileViaYul: also // ---- // g() -> 42 +// gas irOptimized: 127021 +// gas legacy: 180597 +// gas legacyOptimized: 116153 diff --git a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol index 898c979fa..726caf3fa 100644 --- a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol +++ b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol @@ -22,4 +22,6 @@ contract A { // compileViaYul: also // ---- // g(int256): -1 -> -1 +// gas legacy: 103422 // g(int256): 10 -> 10 +// gas legacy: 103050 diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 62213211a..78aff8ede 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -37,5 +37,10 @@ contract C { // compileViaYul: also // ---- // convertParent() -> 1 +// gas irOptimized: 122356 // convertSubA() -> 1, 2 +// gas irOptimized: 124555 +// gas legacy: 101703 // convertSubB() -> 1, 3 +// gas irOptimized: 124489 +// gas legacy: 101637 diff --git a/test/libsolidity/semanticTests/reverts/invalid_instruction.sol b/test/libsolidity/semanticTests/reverts/invalid_instruction.sol index 4ce7527f8..1bb64db6e 100644 --- a/test/libsolidity/semanticTests/reverts/invalid_instruction.sol +++ b/test/libsolidity/semanticTests/reverts/invalid_instruction.sol @@ -7,7 +7,7 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // f() -> FAILURE diff --git a/test/libsolidity/semanticTests/salted_create/salted_create.sol b/test/libsolidity/semanticTests/salted_create/salted_create.sol index 6a08fb18a..8d26c4120 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create.sol @@ -17,8 +17,11 @@ contract A { } } // ==== -// compileViaYul: also // EVMVersion: >=constantinople +// compileViaYul: also // ---- // different_salt() -> true // same_salt() -> true +// gas irOptimized: 98439083 +// gas legacy: 98439116 +// gas legacyOptimized: 98438982 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 277ef14ff..6f9991857 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -18,7 +18,10 @@ contract A { } } // ==== -// compileViaYul: also // EVMVersion: >=constantinople +// compileViaYul: also // ---- // f(), 10 ether -> 3007, 3008, 3009 +// gas irOptimized: 338630 +// gas legacy: 422027 +// gas legacyOptimized: 287256 diff --git a/test/libsolidity/semanticTests/smoke/alignment.sol b/test/libsolidity/semanticTests/smoke/alignment.sol index bb4ba9317..69d9d9287 100644 --- a/test/libsolidity/semanticTests/smoke/alignment.sol +++ b/test/libsolidity/semanticTests/smoke/alignment.sol @@ -27,5 +27,5 @@ contract D { // stateDecimal() -> right(42) // stateBytes() -> left(0x4200ef) // internalStateDecimal() -> 0x20 +// gas legacy: 101607 // update(bool,uint256,bytes32): false, -23, left(0x2300ef) -> false, -23, left(0x2300ef) - diff --git a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol index fe1738265..9084a41ab 100644 --- a/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol +++ b/test/libsolidity/semanticTests/storage/packed_storage_structs_bytes.sol @@ -42,7 +42,10 @@ contract C { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // test() -> true +// gas irOptimized: 143682 +// gas legacy: 143536 +// gas legacyOptimized: 133280 diff --git a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol index efcb2a639..7ce2654d6 100644 --- a/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol +++ b/test/libsolidity/semanticTests/structs/calldata/calldata_struct_with_nested_array_to_storage.sol @@ -17,4 +17,7 @@ contract C { // ==== // compileViaYul: also // ---- -// f(uint32, (uint128, uint256[][2], uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88 +// f(uint32,(uint128,uint256[][2],uint32)): 55, 0x40, 77, 0x60, 88, 0x40, 0x40, 2, 1, 2 -> 55, 77, 1, 2, 88 +// gas irOptimized: 202421 +// gas legacy: 205149 +// gas legacyOptimized: 200516 diff --git a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol index 674871519..f785a2249 100644 --- a/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol +++ b/test/libsolidity/semanticTests/structs/conversion/recursive_storage_memory.sol @@ -25,3 +25,4 @@ contract CopyTest { // compileViaYul: also // ---- // run() -> 2, 23, 42 +// gas irOptimized: 114778 diff --git a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol index 3543bb1b6..26d16f160 100644 --- a/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol +++ b/test/libsolidity/semanticTests/structs/memory_structs_nested_load.sol @@ -68,4 +68,7 @@ contract Test { // compileViaYul: also // ---- // load() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 +// gas irOptimized: 112341 +// gas legacy: 113999 +// gas legacyOptimized: 106281 // store() -> 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 diff --git a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol index e0f8d9fd9..79acbd965 100644 --- a/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol +++ b/test/libsolidity/semanticTests/structs/struct_containing_bytes_copy_and_delete.sol @@ -25,6 +25,9 @@ contract c { // ---- // storage: empty // set(uint256,bytes,uint256): 12, 0x60, 13, 33, "12345678901234567890123456789012", "3" -> true +// gas irOptimized: 124422 +// gas legacy: 124736 +// gas legacyOptimized: 124178 // test(uint256): 32 -> "3" // storage: nonempty // copy() -> true diff --git a/test/libsolidity/semanticTests/structs/struct_copy.sol b/test/libsolidity/semanticTests/structs/struct_copy.sol index 7c9ef9751..c5a743382 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy.sol @@ -38,8 +38,14 @@ contract c { // compileViaYul: also // ---- // set(uint256): 7 -> true +// gas irOptimized: 101963 +// gas legacy: 102216 +// gas legacyOptimized: 101606 // retrieve(uint256): 7 -> 1, 3, 4, 2 // copy(uint256,uint256): 7, 8 -> true +// gas irOptimized: 105289 +// gas legacy: 105566 +// gas legacyOptimized: 105022 // retrieve(uint256): 7 -> 1, 3, 4, 2 // retrieve(uint256): 8 -> 1, 3, 4, 2 // copy(uint256,uint256): 0, 7 -> true diff --git a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol index e81c6e76f..cb2efa54b 100644 --- a/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol +++ b/test/libsolidity/semanticTests/structs/struct_copy_via_local.sol @@ -17,7 +17,10 @@ contract c { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // test() -> true +// gas irOptimized: 101589 +// gas legacy: 106427 +// gas legacyOptimized: 101306 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol index 441c299c3..bff1470f3 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_nested_small.sol @@ -33,3 +33,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0, 0, 0 +// gas irOptimized: 125251 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol index 4194ff15b..01faf0e9a 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol @@ -44,4 +44,7 @@ contract C { // compileViaYul: also // ---- // f() -> +// gas irOptimized: 129606 +// gas legacy: 126832 +// gas legacyOptimized: 125500 // g() -> diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol index 65fb74187..b0a588a89 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_arrays_small.sol @@ -27,3 +27,4 @@ contract C { // compileViaYul: true // ---- // f() -> 0 +// gas irOptimized: 118884 diff --git a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol index f07de1e9f..f95d56e0c 100644 --- a/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol +++ b/test/libsolidity/semanticTests/structs/struct_memory_to_storage_function_ptr.sol @@ -31,3 +31,6 @@ contract C { // compileViaYul: also // ---- // f() -> 42, 23, 34, 42, 42 +// gas irOptimized: 108820 +// gas legacy: 110821 +// gas legacyOptimized: 105148 diff --git a/test/libsolidity/semanticTests/structs/structs.sol b/test/libsolidity/semanticTests/structs/structs.sol index d0f63d892..b8b7de3b8 100644 --- a/test/libsolidity/semanticTests/structs/structs.sol +++ b/test/libsolidity/semanticTests/structs/structs.sol @@ -32,4 +32,7 @@ contract test { // ---- // check() -> false // set() -> +// gas irOptimized: 128686 +// gas legacy: 129577 +// gas legacyOptimized: 126964 // check() -> true diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index f4bd9c5c5..9f38de84a 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -40,4 +40,6 @@ contract C { // compileViaYul: also // ---- // testRuntime() -> true +// gas legacy: 100679 // testCreation() -> true +// gas legacy: 101937 diff --git a/test/libsolidity/semanticTests/various/code_access_create.sol b/test/libsolidity/semanticTests/various/code_access_create.sol index 9b8b3175e..abffae170 100644 --- a/test/libsolidity/semanticTests/various/code_access_create.sol +++ b/test/libsolidity/semanticTests/various/code_access_create.sol @@ -26,3 +26,4 @@ contract C { // compileViaYul: also // ---- // test() -> 7 +// gas legacy: 102192 diff --git a/test/libsolidity/semanticTests/various/code_access_runtime.sol b/test/libsolidity/semanticTests/various/code_access_runtime.sol index 0a55088a2..959ac6a34 100644 --- a/test/libsolidity/semanticTests/various/code_access_runtime.sol +++ b/test/libsolidity/semanticTests/various/code_access_runtime.sol @@ -25,3 +25,4 @@ contract C { // compileViaYul: also // ---- // test() -> 42 +// gas legacy: 100138 diff --git a/test/libsolidity/semanticTests/various/destructuring_assignment.sol b/test/libsolidity/semanticTests/various/destructuring_assignment.sol index 345d76ca1..ab322cb25 100644 --- a/test/libsolidity/semanticTests/various/destructuring_assignment.sol +++ b/test/libsolidity/semanticTests/various/destructuring_assignment.sol @@ -36,3 +36,6 @@ contract C { // compileViaYul: also // ---- // f(bytes): 0x20, 0x5, "abcde" -> 0 +// gas irOptimized: 249042 +// gas legacy: 239258 +// gas legacyOptimized: 238575 diff --git a/test/libsolidity/semanticTests/various/external_types_in_calls.sol b/test/libsolidity/semanticTests/various/external_types_in_calls.sol index 7b3d5def1..923d9197d 100644 --- a/test/libsolidity/semanticTests/various/external_types_in_calls.sol +++ b/test/libsolidity/semanticTests/various/external_types_in_calls.sol @@ -27,4 +27,5 @@ contract C { // compileViaYul: also // ---- // test() -> 9, 7 +// gas legacy: 123394 // t2() -> 9 diff --git a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol index 4e8bfd0e9..2f16b6b51 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -22,3 +22,6 @@ contract C { // compileViaYul: also // ---- // g() -> 2, 6 +// gas irOptimized: 170427 +// gas legacy: 172490 +// gas legacyOptimized: 171206 diff --git a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol index c2f045082..d2277df7e 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -32,9 +32,16 @@ contract D { } } // ==== -// compileViaYul: also // EVMVersion: >=byzantium +// compileViaYul: also // ---- // f() -> 0x1 # This should work, next should throw # +// gas legacy: 102944 // fview() -> FAILURE +// gas irOptimized: 98438674 +// gas legacy: 98438822 +// gas legacyOptimized: 98438615 // fpure() -> FAILURE +// gas irOptimized: 98438674 +// gas legacy: 98438822 +// gas legacyOptimized: 98438616 diff --git a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol index ff6648817..28e214983 100644 --- a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol +++ b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol @@ -24,12 +24,15 @@ contract c { } // ==== -// compileViaYul: also // compileToEwasm: also +// compileViaYul: also // ---- // x() -> 0, 0 // y() -> 0, 0 // set() -> +// gas irOptimized: 101473 +// gas legacy: 101332 +// gas legacyOptimized: 101282 // x() -> 1, 2 // y() -> 3, 4 // swap() -> diff --git a/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol b/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol index 5344ae67f..cabeba207 100644 --- a/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol +++ b/test/libsolidity/semanticTests/viaYul/array_function_pointers.sol @@ -23,7 +23,7 @@ contract C { // ==== // compileViaYul: also // ---- -// f(uint256,uint256): 1823621, 12323 -> FAILURE -// f2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE -// g(uint256,uint256): 1823621, 12323 -> FAILURE -// g2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE +// f(uint256,uint256): 1823621, 12323 -> FAILURE # Out of gas # +// f2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE # Out of gas # +// g(uint256,uint256): 1823621, 12323 -> FAILURE # Out of gas # +// g2(uint256,uint256,uint256,uint256): 18723921, 1823621, 123, 12323 -> FAILURE # Out of gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol index edea7fc3e..cde08e90b 100644 --- a/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_memory_index_access.sol @@ -28,6 +28,9 @@ contract C { // index(uint256): 10 -> true // index(uint256): 20 -> true // index(uint256): 0xFF -> true +// gas irOptimized: 168557 +// gas legacy: 248854 +// gas legacyOptimized: 152640 // accessIndex(uint256,int256): 10, 1 -> 2 // accessIndex(uint256,int256): 10, 0 -> 1 // accessIndex(uint256,int256): 10, 11 -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol index efc67e517..338376418 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol @@ -18,11 +18,33 @@ contract C { // ---- // test_indices(uint256): 1 -> // test_indices(uint256): 129 -> +// gas irOptimized: 3572413 +// gas legacy: 3340105 +// gas legacyOptimized: 3280773 // test_indices(uint256): 5 -> +// gas irOptimized: 684693 +// gas legacy: 458941 +// gas legacyOptimized: 455849 // test_indices(uint256): 10 -> // test_indices(uint256): 15 -> +// gas irOptimized: 115342 // test_indices(uint256): 0xFF -> +// gas irOptimized: 4554277 +// gas legacy: 4107867 +// gas legacyOptimized: 3991807 // test_indices(uint256): 1000 -> +// gas irOptimized: 21917394 +// gas legacy: 20360399 +// gas legacyOptimized: 19921344 // test_indices(uint256): 129 -> +// gas irOptimized: 5135327 +// gas legacy: 3472135 +// gas legacyOptimized: 3415947 // test_indices(uint256): 128 -> +// gas irOptimized: 663783 +// gas legacy: 556972 +// gas legacyOptimized: 508124 // test_indices(uint256): 1 -> +// gas irOptimized: 680239 +// gas legacy: 452407 +// gas legacyOptimized: 450811 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol index db007858c..5dbe09465 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_boundary_test.sol @@ -18,6 +18,12 @@ 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: 678468 +// gas legacy: 648515 +// gas legacyOptimized: 628739 // test_boundary_check(uint256,uint256): 256, 255 -> 0 +// gas irOptimized: 679610 +// gas legacy: 649549 +// gas legacyOptimized: 629633 // test_boundary_check(uint256,uint256): 256, 0xFFFF -> FAILURE, hex"4e487b71", 0x32 // test_boundary_check(uint256,uint256): 256, 2 -> 0 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol index e02dc027d..7519c47ff 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol @@ -54,6 +54,18 @@ contract C { // ---- // test_zeroed_indicies(uint256): 1 -> // test_zeroed_indicies(uint256): 5 -> +// gas irOptimized: 222625 +// gas legacy: 191267 +// gas legacyOptimized: 188486 // test_zeroed_indicies(uint256): 10 -> +// gas irOptimized: 327375 +// gas legacy: 276129 +// gas legacyOptimized: 271024 // test_zeroed_indicies(uint256): 15 -> +// gas irOptimized: 409400 +// gas legacy: 339254 +// gas legacyOptimized: 331904 // test_zeroed_indicies(uint256): 0xFF -> +// gas irOptimized: 9686975 +// gas legacy: 8477449 +// gas legacyOptimized: 8343774 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol index 95ca92782..5ddd3955f 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_length_access.sol @@ -14,5 +14,11 @@ contract C { // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0xFF -> 0xFF +// gas irOptimized: 434473 +// gas legacy: 619622 +// gas legacyOptimized: 600718 // set_get_length(uint256): 0xFFF -> 0xFFF +// gas irOptimized: 6743235 +// gas legacy: 9765519 +// gas legacyOptimized: 9461820 // set_get_length(uint256): 0xFFFFF -> FAILURE # Out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol index 432ab243b..a03d950b8 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol @@ -9,9 +9,15 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >=petersburg +// compileViaYul: also // ---- // pushEmpty(uint256): 128 +// gas irOptimized: 632037 +// gas legacy: 607287 +// gas legacyOptimized: 589048 // pushEmpty(uint256): 256 -// pushEmpty(uint256): 32768 -> FAILURE # out-of-gas # \ No newline at end of file +// gas irOptimized: 862821 +// gas legacy: 828983 +// gas legacyOptimized: 802808 +// pushEmpty(uint256): 32768 -> FAILURE # out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol index e28106443..70befff13 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty_length_address.sol @@ -10,14 +10,23 @@ contract C { } } // ==== -// compileViaYul: also // EVMVersion: >=petersburg +// compileViaYul: also // ---- // set_get_length(uint256): 0 -> 0 // set_get_length(uint256): 1 -> 1 // set_get_length(uint256): 10 -> 10 // set_get_length(uint256): 20 -> 20 // set_get_length(uint256): 0 -> 0 +// gas irOptimized: 110296 +// gas legacy: 107830 +// gas legacyOptimized: 107262 // set_get_length(uint256): 0xFF -> 0xFF +// gas irOptimized: 702388 +// gas legacy: 882337 +// gas legacyOptimized: 650704 // set_get_length(uint256): 0xFFF -> 0xFFF -// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # +// gas irOptimized: 10238500 +// gas legacy: 12945874 +// gas legacyOptimized: 9462646 +// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # \ No newline at end of file diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol index e40223908..fc567c854 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_pop.sol @@ -15,6 +15,15 @@ contract C { // set_get_length(uint256): 1 -> 0 // set_get_length(uint256): 10 -> 0 // set_get_length(uint256): 20 -> 0 +// gas irOptimized: 162779 +// gas legacy: 141922 +// gas legacyOptimized: 139708 // set_get_length(uint256): 0xFF -> 0 +// gas irOptimized: 1792504 +// gas legacy: 1524427 +// gas legacyOptimized: 1500358 // set_get_length(uint256): 0xFFF -> 0 -// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # +// gas irOptimized: 28422916 +// gas legacy: 24115159 +// gas legacyOptimized: 23733970 +// set_get_length(uint256): 0xFFFF -> FAILURE # Out-of-gas # \ No newline at end of file