From a1aa9d2d90f2f7e7390408e9005d62c7159d4bd4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 27 Oct 2021 17:26:44 +0200 Subject: [PATCH] Skip extcodesize check if return data is expected. --- Changelog.md | 1 + libsolidity/codegen/ExpressionCompiler.cpp | 18 +- .../codegen/ir/IRGeneratorForStatements.cpp | 20 +- .../output.json | 190 ++++++++++++++++++ .../output.json | 32 +-- .../abi_encode_calldata_slice.sol | 4 +- .../struct/struct_storage_ptr.sol | 2 +- .../abi_encode_calldata_slice.sol | 4 +- ...2_in_function_inherited_in_v1_contract.sol | 2 +- ...ode_v2_in_modifier_used_in_v1_contract.sol | 2 +- .../abiEncoderV2/calldata_array.sol | 2 +- .../arithmetics/check_var_init.sol | 2 +- .../array/fixed_arrays_as_return_type.sol | 2 +- .../array/function_array_cross_calls.sol | 2 +- .../semanticTests/array/reusing_memory.sol | 2 +- .../constructor/arrays_in_constructors.sol | 2 +- .../bytes_in_constructors_packer.sol | 2 +- .../constructor_function_complex.sol | 2 +- .../freeFunctions/new_operator.sol | 2 +- .../creation_function_call_no_args.sol | 2 +- .../functionCall/failed_create.sol | 4 +- .../functionTypes/store_function.sol | 2 +- .../immutable/multi_creation.sol | 2 +- .../address_overload_resolution.sol | 4 +- ...d_function_calldata_calldata_interface.sol | 2 +- ...ted_function_calldata_memory_interface.sol | 2 +- .../inheritance/member_notation_ctor.sol | 4 +- .../interface_inheritance_conversions.sol | 4 +- .../salted_create_with_value.sol | 2 +- .../semanticTests/smoke/alignment.sol | 2 +- .../various/code_access_content.sol | 2 +- .../various/code_access_create.sol | 2 +- .../various/external_types_in_calls.sol | 2 +- .../skip_dynamic_types_for_structs.sol | 2 +- .../various/staticcall_for_view_and_pure.sol | 6 +- 35 files changed, 270 insertions(+), 67 deletions(-) diff --git a/Changelog.md b/Changelog.md index f02004437..54088143b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,7 @@ Language Features: Compiler Features: + * Code Generator: Skip existence check for external contract if return data is expected. In this case, the ABI decoder will revert if the contract does not exist. * Commandline Interface: Accept nested brackets in step sequences passed to ``--yul-optimizations``. * Commandline Interface: Add ``--debug-info`` option for selecting how much extra debug information should be included in the produced EVM assembly and Yul code. * Commandline Interface: Use different colors when printing errors, warnings and infos. diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 731cf1a41..07d37c4c5 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -2630,9 +2630,21 @@ void ExpressionCompiler::appendExternalFunctionCall( // Check the target contract exists (has code) for non-low-level calls. if (funKind == FunctionType::Kind::External || funKind == FunctionType::Kind::DelegateCall) { - m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO; - m_context.appendConditionalRevert(false, "Target contract does not contain code"); - existenceChecked = true; + size_t encodedHeadSize = 0; + for (auto const& t: returnTypes) + encodedHeadSize += t->decodingType()->calldataHeadSize(); + // We do not need to check extcodesize if we expect return data, since if there is no + // code, the call will return empty data and the ABI decoder will revert. + if ( + encodedHeadSize == 0 || + !haveReturndatacopy || + m_context.revertStrings() >= RevertStrings::Debug + ) + { + m_context << Instruction::DUP1 << Instruction::EXTCODESIZE << Instruction::ISZERO; + m_context.appendConditionalRevert(false, "Target contract does not contain code"); + existenceChecked = true; + } } if (_functionType.gasSet()) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 6d7ee86f5..85b21bbdc 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -2451,8 +2451,10 @@ void IRGeneratorForStatements::appendExternalFunctionCall( appendCode() << "mstore(add(" << m_utils.allocateUnboundedFunction() << "() , " << to_string(returnInfo.estimatedReturnSize) << "), 0)\n"; } - Whiskers templ(R"(if iszero(extcodesize(
)) { () } - + Whiskers templ(R"( + + if iszero(extcodesize(
)) { () } + // storage for arguments and returned data let := () mstore(, ()) @@ -2477,6 +2479,18 @@ void IRGeneratorForStatements::appendExternalFunctionCall( } )"); templ("revertNoCode", m_utils.revertReasonIfDebugFunction("Target contract does not contain code")); + + // We do not need to check extcodesize if we expect return data: If there is no + // code, the call will return empty data and the ABI decoder will revert. + size_t encodedHeadSize = 0; + for (auto const& t: returnInfo.returnTypes) + encodedHeadSize += t->decodingType()->calldataHeadSize(); + bool const checkExtcodesize = + encodedHeadSize == 0 || + !m_context.evmVersion().supportsReturndata() || + m_context.revertStrings() >= RevertStrings::Debug; + templ("checkExtcodesize", checkExtcodesize); + templ("pos", m_context.newYulVariable()); templ("end", m_context.newYulVariable()); if (_functionCall.annotation().tryCall) @@ -2532,6 +2546,8 @@ void IRGeneratorForStatements::appendExternalFunctionCall( u256 gasNeededByCaller = evmasm::GasCosts::callGas(m_context.evmVersion()) + 10; if (funType.valueSet()) gasNeededByCaller += evmasm::GasCosts::callValueTransferGas; + if (!checkExtcodesize) + gasNeededByCaller += evmasm::GasCosts::callNewAccountGas; // we never know templ("gas", "sub(gas(), " + formatNumber(gasNeededByCaller) + ")"); } // Order is important here, STATICCALL might overlap with DELEGATECALL. diff --git a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json index 0c529109a..773637b32 100644 --- a/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_evm_asm_via_ir_location/output.json @@ -289,6 +289,19 @@ sub_0: assembly { address /* \"C\":403:411 this.f() */ extcodesize + tag_40 + jumpi + /* \"C\":79:428 contract C... */ + dup2 + dup3 + revert + /* \"C\":403:411 this.f() */ + tag_40: + /* \"C\":79:428 contract C... */ + /* \"C\":403:407 this */ + address + /* \"C\":403:411 this.f() */ + extcodesize iszero tag_43 jumpi @@ -316,6 +329,8 @@ sub_0: assembly { tag_45 jumpi dup1 + tag_41 + tag_40 swap3 tag_47 jumpi @@ -344,12 +359,22 @@ sub_0: assembly { swap1 jump\t// out /* \"C\":403:411 this.f() */ + tag_41: + tag_40: tag_47: /* \"C\":79:428 contract C... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ + dup2 + iszero + tag_42 + jumpi + dup2 + iszero + tag_41 + jumpi returndatasize /* \"C\":79:428 contract C... */ 0x1f @@ -366,6 +391,10 @@ sub_0: assembly { dup4 lt or + iszero + tag_43 + iszero + tag_42 tag_51 jumpi pop @@ -379,26 +408,56 @@ sub_0: assembly { /* \"C\":392:422 stateVar + this.f() + immutVar */ tag_50 /* \"C\":79:428 contract C... */ + mstore + 0x24 + dup7 + revert + tag_43: + mstore + 0x24 + dup7 + revert + tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ + tag_44 + tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in + tag_44: + swap1 + tag_43: + swap1 tag_53: swap2 dup2 swap4 pop + tag_42: + /* \"C\":392:411 stateVar + this.f() */ + tag_45 + tag_41: + /* \"C\":392:411 stateVar + this.f() */ + tag_44 jump(tag_48) /* \"C\":79:428 contract C... */ tag_51: shl(0xe0, 0x4e487b71) dup2 + dup6 + tag_5 + jump\t// in + tag_45: + dup6 + tag_5 + jump\t// in + tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -422,12 +481,30 @@ sub_0: assembly { pop pop pop + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_46 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_45 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ pop mload(0x40) swap1 returndatasize swap1 dup3 + tag_5 + jump\t// in + tag_46: + /* \"C\":336:337 _ */ + tag_5 + jump\t// in + tag_45: + /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 @@ -453,6 +530,10 @@ sub_0: assembly { swap2 sub slt + iszero + tag_48 + iszero + tag_47 tag_55 jumpi mload @@ -464,6 +545,20 @@ sub_0: assembly { 0x00 dup1 revert + tag_48: + pop + mload + swap2 + swap1 + pop + jump\t// out + tag_47: + pop + mload + swap2 + swap1 + pop + jump\t// out auxdata: } @@ -799,6 +894,19 @@ sub_0: assembly { address /* \"C\":403:411 this.f() */ extcodesize + tag_40 + jumpi + /* \"D\":91:166 contract D is C(3)... */ + dup2 + dup3 + revert + /* \"C\":403:411 this.f() */ + tag_40: + /* \"D\":91:166 contract D is C(3)... */ + /* \"C\":403:407 this */ + address + /* \"C\":403:411 this.f() */ + extcodesize iszero tag_43 jumpi @@ -826,6 +934,8 @@ sub_0: assembly { tag_45 jumpi dup1 + tag_41 + tag_40 swap3 tag_47 jumpi @@ -854,12 +964,22 @@ sub_0: assembly { swap1 jump\t// out /* \"C\":403:411 this.f() */ + tag_41: + tag_40: tag_47: /* \"D\":91:166 contract D is C(3)... */ swap1 swap2 pop /* \"C\":403:411 this.f() */ + dup2 + iszero + tag_42 + jumpi + dup2 + iszero + tag_41 + jumpi returndatasize /* \"D\":91:166 contract D is C(3)... */ 0x1f @@ -876,6 +996,10 @@ sub_0: assembly { dup4 lt or + iszero + tag_43 + iszero + tag_42 tag_51 jumpi pop @@ -889,26 +1013,56 @@ sub_0: assembly { /* \"C\":392:422 stateVar + this.f() + immutVar */ tag_50 /* \"D\":91:166 contract D is C(3)... */ + mstore + 0x24 + dup7 + revert + tag_43: + mstore + 0x24 + dup7 + revert + tag_42: swap5 0x40 mstore /* \"C\":403:411 this.f() */ + tag_44 + tag_43 returndatasize dup2 add swap1 tag_7 jump\t// in + tag_44: + swap1 + tag_43: + swap1 tag_53: swap2 dup2 swap4 pop + tag_42: + /* \"C\":392:411 stateVar + this.f() */ + tag_45 + tag_41: + /* \"C\":392:411 stateVar + this.f() */ + tag_44 jump(tag_48) /* \"D\":91:166 contract D is C(3)... */ tag_51: shl(0xe0, 0x4e487b71) dup2 + dup6 + tag_5 + jump\t// in + tag_45: + dup6 + tag_5 + jump\t// in + tag_44: mstore 0x41 /* \"C\":403:411 this.f() */ @@ -931,6 +1085,16 @@ sub_0: assembly { swap4 pop pop + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_46 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ + /* \"C\":392:422 stateVar + this.f() + immutVar */ + tag_45 + /* \"C\":414:422 immutVar */ + immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\") + /* \"C\":392:422 stateVar + this.f() + immutVar */ pop pop mload(0x40) @@ -938,6 +1102,14 @@ sub_0: assembly { returndatasize swap1 dup3 + tag_5 + jump\t// in + tag_46: + /* \"C\":336:337 _ */ + tag_5 + jump\t// in + tag_45: + /* \"C\":336:337 _ */ returndatacopy returndatasize swap1 @@ -963,6 +1135,10 @@ sub_0: assembly { swap2 sub slt + iszero + tag_48 + iszero + tag_47 tag_55 jumpi mload @@ -974,6 +1150,20 @@ sub_0: assembly { 0x00 dup1 revert + tag_48: + pop + mload + swap2 + swap1 + pop + jump\t// out + tag_47: + pop + mload + swap2 + swap1 + pop + jump\t// out auxdata: } diff --git a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json index 6a105aadd..2acd68ff7 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_location/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_location/output.json @@ -526,7 +526,6 @@ object \"C_54\" { let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data let _10 := allocate_unbounded() @@ -640,7 +639,7 @@ object \"C_54\" { case 0x26121ff0 { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) - let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_556(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) /// @src 0:79:435 \"contract C...\" let memPos := mload(64) return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) @@ -664,7 +663,7 @@ object \"C_54\" { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) let memPos_3 := mload(64) - return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3)) + return(memPos_3, sub(abi_encode_int256_555(memPos_3), memPos_3)) } } revert(0, 0) @@ -673,7 +672,7 @@ object \"C_54\" { { if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } } - function abi_encode_int256_565(headStart) -> tail + function abi_encode_int256_555(headStart) -> tail { tail := add(headStart, 32) mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) @@ -690,7 +689,7 @@ object \"C_54\" { mstore(4, 0x11) revert(0, 0x24) } - function checked_add_int256_566(y) -> sum + function checked_add_int256_556(y) -> sum { if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 0:79:435 \"contract C...\" */ y) @@ -712,13 +711,6 @@ object \"C_54\" { let ret := add(_3, 1) sstore(_2, ret) /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) - /// @src 0:410:418 \"this.f()\" - { - /// @src 0:79:435 \"contract C...\" - revert(_2, _2) - } - /// @src 0:410:418 \"this.f()\" let _4 := /** @src 0:79:435 \"contract C...\" */ mload(64) /// @src 0:410:418 \"this.f()\" mstore(_4, /** @src 0:79:435 \"contract C...\" */ shl(228, 0x026121ff)) @@ -1359,7 +1351,6 @@ object \"D_72\" { let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data let _10 := allocate_unbounded() @@ -1481,7 +1472,7 @@ object \"D_72\" { case 0x26121ff0 { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) - let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_566(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_556(/** @src 0:297:305 \"immutVar\" */ loadimmutable(\"8\")) /// @src 1:91:166 \"contract D is C(3)...\" let memPos := mload(64) return(memPos, sub(abi_encode_int256(memPos, ret), memPos)) @@ -1505,7 +1496,7 @@ object \"D_72\" { if callvalue() { revert(_1, _1) } abi_decode(calldatasize()) let memPos_3 := mload(64) - return(memPos_3, sub(abi_encode_int256_565(memPos_3), memPos_3)) + return(memPos_3, sub(abi_encode_int256_555(memPos_3), memPos_3)) } } revert(0, 0) @@ -1514,7 +1505,7 @@ object \"D_72\" { { if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } } - function abi_encode_int256_565(headStart) -> tail + function abi_encode_int256_555(headStart) -> tail { tail := add(headStart, 32) mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) @@ -1531,7 +1522,7 @@ object \"D_72\" { mstore(4, 0x11) revert(0, 0x24) } - function checked_add_int256_566(y) -> sum + function checked_add_int256_556(y) -> sum { if and(1, sgt(y, sub(shl(255, 1), 42))) { panic_error_0x11() } sum := add(/** @src 0:124:126 \"41\" */ 0x29, /** @src 1:91:166 \"contract D is C(3)...\" */ y) @@ -1553,13 +1544,6 @@ object \"D_72\" { let ret := add(_3, 1) sstore(_2, ret) /// @src 0:410:418 \"this.f()\" - if iszero(extcodesize(/** @src 0:410:414 \"this\" */ address())) - /// @src 0:410:418 \"this.f()\" - { - /// @src 1:91:166 \"contract D is C(3)...\" - revert(_2, _2) - } - /// @src 0:410:418 \"this.f()\" let _4 := /** @src 1:91:166 \"contract D is C(3)...\" */ mload(64) /// @src 0:410:418 \"this.f()\" mstore(_4, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(228, 0x026121ff)) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index ddd536a38..947f5cb23 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -61,9 +61,9 @@ contract C { // ---- // test_bytes() -> // gas irOptimized: 377545 -// gas legacy: 423563 +// gas legacy: 418955 // gas legacyOptimized: 331391 // test_uint256() -> // gas irOptimized: 528726 -// gas legacy: 591392 +// gas legacy: 586784 // gas legacyOptimized: 456137 diff --git a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol index 8fe170e91..886d9dfd9 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/struct/struct_storage_ptr.sol @@ -27,5 +27,5 @@ contract C { // library: L // f() -> 8, 7, 1, 2, 7, 12 // gas irOptimized: 167580 -// gas legacy: 169475 +// gas legacy: 169347 // gas legacyOptimized: 167397 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 3a4a23fef..f75eecfb5 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -62,9 +62,9 @@ contract C { // ---- // test_bytes() -> // gas irOptimized: 377545 -// gas legacy: 423563 +// gas legacy: 418955 // gas legacyOptimized: 331391 // test_uint256() -> // gas irOptimized: 528726 -// gas legacy: 591392 +// gas legacy: 586784 // gas legacyOptimized: 456137 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 b730f3588..49b93cbbc 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 @@ -33,5 +33,5 @@ contract C is B { // ---- // test() -> 77 // gas irOptimized: 120044 -// gas legacy: 155221 +// gas legacy: 155093 // gas legacyOptimized: 111678 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 7832ef601..28658089a 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 @@ -41,4 +41,4 @@ contract C is B { // ---- // test() -> 5, 10 // gas irOptimized: 87578 -// gas legacy: 99137 +// gas legacy: 98881 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol index bf42f8776..131430aa5 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_array.sol @@ -22,5 +22,5 @@ contract C { // 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: 172204 -// gas legacy: 141900 +// gas legacy: 141644 // gas legacyOptimized: 121788 diff --git a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol index f8e4ca2a4..7e3edc127 100644 --- a/test/libsolidity/semanticTests/arithmetics/check_var_init.sol +++ b/test/libsolidity/semanticTests/arithmetics/check_var_init.sol @@ -18,4 +18,4 @@ contract D { // ---- // f() -> FAILURE, hex"4e487b71", 0x11 // g(), 100 wei -> 1 -// gas legacy: 101918 +// gas legacy: 101790 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 5e30621af..063e0bf9c 100644 --- a/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol +++ b/test/libsolidity/semanticTests/array/fixed_arrays_as_return_type.sol @@ -22,5 +22,5 @@ contract B { // ---- // f() -> 2, 3, 4, 5, 6, 1000, 1001, 1002, 1003, 1004 // gas irOptimized: 130328 -// gas legacy: 235199 +// gas legacy: 234943 // gas legacyOptimized: 133119 diff --git a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol index 95cb52f11..6edae7198 100644 --- a/test/libsolidity/semanticTests/array/function_array_cross_calls.sol +++ b/test/libsolidity/semanticTests/array/function_array_cross_calls.sol @@ -46,5 +46,5 @@ contract C { // ---- // test() -> 5, 6, 7 // gas irOptimized: 302321 -// gas legacy: 462080 +// gas legacy: 452172 // gas legacyOptimized: 294938 diff --git a/test/libsolidity/semanticTests/array/reusing_memory.sol b/test/libsolidity/semanticTests/array/reusing_memory.sol index 7d2b4d995..a8a534b92 100644 --- a/test/libsolidity/semanticTests/array/reusing_memory.sol +++ b/test/libsolidity/semanticTests/array/reusing_memory.sol @@ -27,5 +27,5 @@ contract Main { // ---- // f(uint256): 0x34 -> 0x46bddb1178e94d7f2892ff5f366840eb658911794f2c3a44c450aa2c505186c1 // gas irOptimized: 113776 -// gas legacy: 126852 +// gas legacy: 126596 // gas legacyOptimized: 114079 diff --git a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol index 63c2acbb5..7016e6c6e 100644 --- a/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol +++ b/test/libsolidity/semanticTests/constructor/arrays_in_constructors.sol @@ -27,5 +27,5 @@ contract Creator { // ---- // f(uint256,address[]): 7, 0x40, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 -> 7, 8 // gas irOptimized: 456873 -// gas legacy: 590939 +// gas legacy: 590683 // gas legacyOptimized: 448582 diff --git a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol index d4d41d80c..1aba4c7c4 100644 --- a/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol +++ b/test/libsolidity/semanticTests/constructor/bytes_in_constructors_packer.sol @@ -27,5 +27,5 @@ contract Creator { // ---- // f(uint256,bytes): 7, 0x40, 78, "abcdefghijklmnopqrstuvwxyzabcdef", "ghijklmnopqrstuvwxyzabcdefghijkl", "mnopqrstuvwxyz" -> 7, "h" // gas irOptimized: 308702 -// gas legacy: 429173 +// gas legacy: 428917 // gas legacyOptimized: 298384 diff --git a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol index 78466f3f0..f1043f559 100644 --- a/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol +++ b/test/libsolidity/semanticTests/constructor/constructor_function_complex.sol @@ -19,4 +19,4 @@ contract C { // compileViaYul: also // ---- // f() -> 16 -// gas legacy: 103744 +// gas legacy: 103488 diff --git a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol index 1694b64d5..0e89c7560 100644 --- a/test/libsolidity/semanticTests/freeFunctions/new_operator.sol +++ b/test/libsolidity/semanticTests/freeFunctions/new_operator.sol @@ -15,4 +15,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 -// gas legacy: 101754 +// gas legacy: 101626 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 8546c775e..0ab6fe0c3 100644 --- a/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol +++ b/test/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol @@ -13,4 +13,4 @@ contract D { // compileViaYul: also // ---- // f() -> 2 -// gas legacy: 101727 +// gas legacy: 101599 diff --git a/test/libsolidity/semanticTests/functionCall/failed_create.sol b/test/libsolidity/semanticTests/functionCall/failed_create.sol index b50890f55..49c6a80a9 100644 --- a/test/libsolidity/semanticTests/functionCall/failed_create.sol +++ b/test/libsolidity/semanticTests/functionCall/failed_create.sol @@ -19,7 +19,7 @@ contract C { // ---- // constructor(), 20 wei // gas irOptimized: 220113 -// gas legacy: 288299 +// gas legacy: 294569 // gas legacyOptimized: 177933 // f(uint256): 20 -> 1370859564726510389319704988634906228201275401179 // x() -> 1 @@ -27,7 +27,7 @@ contract C { // x() -> 1 // stack(uint256): 1023 -> FAILURE // gas irOptimized: 345821 -// gas legacy: 535367 +// gas legacy: 483942 // gas legacyOptimized: 354656 // x() -> 1 // stack(uint256): 10 -> 693016686122178122849713379390321835634789309880 diff --git a/test/libsolidity/semanticTests/functionTypes/store_function.sol b/test/libsolidity/semanticTests/functionTypes/store_function.sol index c2678a91d..9200bd120 100644 --- a/test/libsolidity/semanticTests/functionTypes/store_function.sol +++ b/test/libsolidity/semanticTests/functionTypes/store_function.sol @@ -29,5 +29,5 @@ contract C { // ---- // t() -> 9 // gas irOptimized: 99186 -// gas legacy: 159083 +// gas legacy: 158955 // gas legacyOptimized: 108916 diff --git a/test/libsolidity/semanticTests/immutable/multi_creation.sol b/test/libsolidity/semanticTests/immutable/multi_creation.sol index cd5992ce6..d4300cfe1 100644 --- a/test/libsolidity/semanticTests/immutable/multi_creation.sol +++ b/test/libsolidity/semanticTests/immutable/multi_creation.sol @@ -30,7 +30,7 @@ contract C { // ---- // f() -> 3, 7, 5 // gas irOptimized: 127592 -// gas legacy: 151590 +// gas legacy: 151334 // gas legacyOptimized: 125422 // 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 0dc9845f4..8c9c6195c 100644 --- a/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol +++ b/test/libsolidity/semanticTests/inheritance/address_overload_resolution.sol @@ -24,7 +24,7 @@ contract D { // ---- // f() -> 1 // gas irOptimized: 77164 -// gas legacy: 115012 +// gas legacy: 114884 // g() -> 5 // gas irOptimized: 77231 -// gas legacy: 115558 +// gas legacy: 115430 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 e012accaf..7322e5f96 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_calldata_interface.sol @@ -26,4 +26,4 @@ contract B { // ---- // g() -> 42 // gas irOptimized: 80945 -// gas legacy: 125609 +// gas legacy: 125481 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 4105577f0..9b5f9778c 100644 --- a/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol +++ b/test/libsolidity/semanticTests/inheritance/inherited_function_calldata_memory_interface.sol @@ -26,5 +26,5 @@ contract B { // ---- // g() -> 42 // gas irOptimized: 111913 -// gas legacy: 185181 +// gas legacy: 185053 // gas legacyOptimized: 114726 diff --git a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol index 9a095cc21..a400531ca 100644 --- a/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol +++ b/test/libsolidity/semanticTests/inheritance/member_notation_ctor.sol @@ -22,6 +22,6 @@ contract A { // compileViaYul: also // ---- // g(int256): -1 -> -1 -// gas legacy: 103622 +// gas legacy: 103494 // g(int256): 10 -> 10 -// gas legacy: 103250 +// gas legacy: 103122 diff --git a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol index 11cb93832..5dfeb9a69 100644 --- a/test/libsolidity/semanticTests/interface_inheritance_conversions.sol +++ b/test/libsolidity/semanticTests/interface_inheritance_conversions.sol @@ -40,7 +40,7 @@ contract C { // gas irOptimized: 85640 // convertSubA() -> 1, 2 // gas irOptimized: 86395 -// gas legacy: 99303 +// gas legacy: 99047 // convertSubB() -> 1, 3 // gas irOptimized: 86338 -// gas legacy: 99237 +// gas legacy: 98981 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 17edaf3eb..2d1070e2a 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -23,5 +23,5 @@ contract A { // ---- // f(), 10 ether -> 3007, 3008, 3009 // gas irOptimized: 273275 -// gas legacy: 422885 +// gas legacy: 422501 // gas legacyOptimized: 287856 diff --git a/test/libsolidity/semanticTests/smoke/alignment.sol b/test/libsolidity/semanticTests/smoke/alignment.sol index 143473461..80c69bb43 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: 101807 +// gas legacy: 101679 // update(bool,uint256,bytes32): false, -23, left(0x2300ef) -> false, -23, left(0x2300ef) diff --git a/test/libsolidity/semanticTests/various/code_access_content.sol b/test/libsolidity/semanticTests/various/code_access_content.sol index 3f8d56587..39ac71b54 100644 --- a/test/libsolidity/semanticTests/various/code_access_content.sol +++ b/test/libsolidity/semanticTests/various/code_access_content.sol @@ -42,4 +42,4 @@ contract C { // testRuntime() -> true // gas legacy: 101579 // testCreation() -> true -// gas legacy: 102137 +// gas legacy: 102009 diff --git a/test/libsolidity/semanticTests/various/code_access_create.sol b/test/libsolidity/semanticTests/various/code_access_create.sol index c32135fe5..ce0d6305d 100644 --- a/test/libsolidity/semanticTests/various/code_access_create.sol +++ b/test/libsolidity/semanticTests/various/code_access_create.sol @@ -26,4 +26,4 @@ contract C { // compileViaYul: also // ---- // test() -> 7 -// gas legacy: 102392 +// gas legacy: 102264 diff --git a/test/libsolidity/semanticTests/various/external_types_in_calls.sol b/test/libsolidity/semanticTests/various/external_types_in_calls.sol index 229e93fc1..1b50465b4 100644 --- a/test/libsolidity/semanticTests/various/external_types_in_calls.sol +++ b/test/libsolidity/semanticTests/various/external_types_in_calls.sol @@ -27,5 +27,5 @@ contract C { // compileViaYul: also // ---- // test() -> 9, 7 -// gas legacy: 130016 +// gas legacy: 129760 // 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 8ef472136..25d7b3c78 100644 --- a/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol +++ b/test/libsolidity/semanticTests/various/skip_dynamic_types_for_structs.sol @@ -23,5 +23,5 @@ contract C { // ---- // g() -> 2, 6 // gas irOptimized: 178953 -// gas legacy: 180890 +// gas legacy: 180762 // gas legacyOptimized: 179609 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 ab6d6e59a..cc910826b 100644 --- a/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol +++ b/test/libsolidity/semanticTests/various/staticcall_for_view_and_pure.sol @@ -36,12 +36,12 @@ contract D { // compileViaYul: also // ---- // f() -> 0x1 # This should work, next should throw # -// gas legacy: 103844 +// gas legacy: 103716 // fview() -> FAILURE // gas irOptimized: 98438627 -// gas legacy: 98438803 +// gas legacy: 98438801 // gas legacyOptimized: 98438596 // fpure() -> FAILURE // gas irOptimized: 98438627 -// gas legacy: 98438803 +// gas legacy: 98438801 // gas legacyOptimized: 98438597