diff --git a/test/cmdlineTests/standard_yul_source_locations/input.json b/test/cmdlineTests/standard_yul_source_locations/input.json index ce5c4b626..8ba84239a 100644 --- a/test/cmdlineTests/standard_yul_source_locations/input.json +++ b/test/cmdlineTests/standard_yul_source_locations/input.json @@ -4,7 +4,7 @@ { "C": { - "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" + "content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int public constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n" }, "D": { @@ -15,7 +15,8 @@ { "outputSelection": { - "*": { "*": ["ir"] } - } + "*": { "*": ["ir", "irOptimized"] } + }, + "optimizer": { "enabled": true } } } diff --git a/test/cmdlineTests/standard_yul_source_locations/output.json b/test/cmdlineTests/standard_yul_source_locations/output.json index 8d0cd3c11..485380625 100644 --- a/test/cmdlineTests/standard_yul_source_locations/output.json +++ b/test/cmdlineTests/standard_yul_source_locations/output.json @@ -9,7 +9,7 @@ /// @use-src 0:\"C\" object \"C_54\" { code { - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" mstore(64, 160) if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } @@ -136,31 +136,31 @@ object \"C_54\" { } /// @ast-id 20 - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" - /// @src 0:147:149 \"42\" + /// @src 0:154:156 \"42\" let expr_7 := 0x2a let _3 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _3) - /// @src 0:214:219 \"_init\" + /// @src 0:221:226 \"_init\" let _4 := var__init_12 let expr_16 := _4 - /// @src 0:203:219 \"stateVar = _init\" + /// @src 0:210:226 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" } /// @use-src 0:\"C\" object \"C_54_deployed\" { code { - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" mstore(64, 128) if iszero(lt(calldatasize(), 4)) @@ -204,6 +204,18 @@ object \"C_54\" { return(memPos, sub(memEnd, memPos)) } + case 0xa00b982b + { + // constVar() + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + abi_decode_tuple_(4, calldatasize()) + let ret_0 := getter_fun_constVar_5() + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple_t_int256__to_t_int256__fromStack(memPos , ret_0) + return(memPos, sub(memEnd, memPos)) + } + default {} } if iszero(calldatasize()) { } @@ -269,7 +281,7 @@ object \"C_54\" { } /// @ast-id 10 - /// @src 0:152:171 \"int public stateVar\" + /// @src 0:159:178 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -278,15 +290,7 @@ object \"C_54\" { ret := read_from_storage_split_dynamic_t_int256(slot, offset) } - /// @src 0:79:428 \"contract C...\" - - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - function zero_value_for_split_t_int256() -> ret { - ret := 0 - } + /// @src 0:79:435 \"contract C...\" function cleanup_t_rational_41_by_1(value) -> cleaned { cleaned := value @@ -300,13 +304,28 @@ object \"C_54\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:119 \"int constant constVar = 41\" + /// @src 0:93:126 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:117:119 \"41\" + /// @src 0:124:126 \"41\" let expr_4 := 0x29 - let _2 := convert_t_rational_41_by_1_to_t_int256(expr_4) + let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) - ret := _2 + ret := _1 + } + + /// @ast-id 5 + /// @src 0:93:126 \"int public constant constVar = 41\" + function getter_fun_constVar_5() -> ret_0 { + ret_0 := constant_constVar_5() + } + /// @src 0:79:435 \"contract C...\" + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function zero_value_for_split_t_int256() -> ret { + ret := 0 } function panic_error_0x11() { @@ -328,26 +347,26 @@ object \"C_54\" { } /// @ast-id 30 - /// @src 0:226:302 \"function f() external pure returns (int)...\" + /// @src 0:233:309 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:262:265 \"int\" - let zero_t_int256_1 := zero_value_for_split_t_int256() - var__23 := zero_t_int256_1 + /// @src 0:269:272 \"int\" + let zero_t_int256_2 := zero_value_for_split_t_int256() + var__23 := zero_t_int256_2 - /// @src 0:279:287 \"constVar\" + /// @src 0:286:294 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:290:298 \"immutVar\" + /// @src 0:297:305 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:279:298 \"constVar + immutVar\" + /// @src 0:286:305 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:272:298 \"return constVar + immutVar\" + /// @src 0:279:305 \"return constVar + immutVar\" var__23 := expr_27 leave } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" function shift_right_0_unsigned(value) -> newValue { newValue := @@ -399,20 +418,20 @@ object \"C_54\" { } /// @ast-id 37 - /// @src 0:304:341 \"modifier m()...\" + /// @src 0:311:348 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:322:332 \"stateVar++\" + /// @src 0:329:339 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:336:337 \"_\" + /// @src 0:343:344 \"_\" _5 := fun_f2_53_inner(var__42) } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" function cleanup_t_uint160(value) -> cleaned { cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffff) @@ -494,19 +513,19 @@ object \"C_54\" { revert(pos, returndatasize()) } - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:392:400 \"stateVar\" + /// @src 0:399:407 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:403:407 \"this\" + /// @src 0:410:414 \"this\" let expr_45_address := address() - /// @src 0:403:409 \"this.f\" + /// @src 0:410:416 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:403:411 \"this.f()\" + /// @src 0:410:418 \"this.f()\" if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data @@ -527,32 +546,32 @@ object \"C_54\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, returndatasize())) } - /// @src 0:392:411 \"stateVar + this.f()\" + /// @src 0:399:418 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:414:422 \"immutVar\" + /// @src 0:421:429 \"immutVar\" let _13 := loadimmutable(\"8\") let expr_49 := _13 - /// @src 0:392:422 \"stateVar + this.f() + immutVar\" + /// @src 0:399:429 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:385:422 \"return stateVar + this.f() + immutVar\" + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" /// @ast-id 53 - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:375:378 \"int\" + /// @src 0:382:385 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 var__42 := modifier_m_40(var__42) } - /// @src 0:79:428 \"contract C...\" + /// @src 0:79:435 \"contract C...\" } @@ -561,6 +580,188 @@ object \"C_54\" { } +","irOptimized":"/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\" +object \"C_54\" { + code { + { + /// @src 0:79:435 \"contract C...\" + mstore(64, 160) + if callvalue() { revert(0, 0) } + let programSize := datasize(\"C_54\") + let argSize := sub(codesize(), programSize) + let newFreePtr := add(160, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, 160)) + { + mstore(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(/** @src -1:-1:-1 */ 0, /** @src 0:79:435 \"contract C...\" */ 0x24) + } + mstore(64, newFreePtr) + codecopy(160, programSize, argSize) + if slt(argSize, 32) + { + revert(/** @src -1:-1:-1 */ 0, 0) + } + /// @src 0:79:435 \"contract C...\" + constructor_C(mload(160)) + let _1 := mload(64) + let _2 := datasize(\"C_54_deployed\") + codecopy(_1, dataoffset(\"C_54_deployed\"), _2) + setimmutable(_1, \"8\", mload(128)) + return(_1, _2) + } + /// @ast-id 20 @src 0:182:230 \"constructor(int _init)...\" + function constructor_C(var_init) + { + /// @src 0:154:156 \"42\" + mstore(128, 0x2a) + /// @src 0:79:435 \"contract C...\" + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 0:79:435 \"contract C...\" */ var_init) + } + } + /// @use-src 0:\"C\" + object \"C_54_deployed\" { + code { + { + /// @src 0:79:435 \"contract C...\" + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + switch shr(224, calldataload(_1)) + case 0x26121ff0 { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @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)) + } + case 0x793816ec { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_1 := sload(_1) + let memPos_1 := mload(64) + return(memPos_1, sub(abi_encode_int256(memPos_1, ret_1), memPos_1)) + } + case 0x9942ec6f { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_2 := /** @src 0:382:385 \"int\" */ modifier_m() + /// @src 0:79:435 \"contract C...\" + let memPos_2 := mload(64) + return(memPos_2, sub(abi_encode_int256(memPos_2, ret_2), memPos_2)) + } + case 0xa00b982b { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let memPos_3 := mload(64) + return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3)) + } + } + revert(0, 0) + } + function abi_decode(dataEnd) + { + if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } + } + function abi_encode_int256_567(headStart) -> tail + { + tail := add(headStart, 32) + mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) + } + /// @src 0:79:435 \"contract C...\" + function abi_encode_int256(headStart, value0) -> tail + { + tail := add(headStart, 32) + mstore(headStart, value0) + } + function panic_error_0x11() + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } + function checked_add_int256_568(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) + } + function checked_add_int256(x, y) -> sum + { + let _1 := slt(x, 0) + if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } + if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } + sum := add(x, y) + } + /// @ast-id 37 @src 0:311:348 \"modifier m()...\" + function modifier_m() -> _1 + { + /// @src 0:79:435 \"contract C...\" + let _2 := 0 + let _3 := sload(_2) + if eq(_3, sub(shl(255, 1), 1)) { panic_error_0x11() } + 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)) + /// @src 0:410:418 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _4, 4, _4, 32) + if iszero(_5) + { + /// @src 0:79:435 \"contract C...\" + let pos := mload(64) + returndatacopy(pos, _2, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 0:79:435 \"contract C...\" */ _2 + /// @src 0:410:418 \"this.f()\" + if _5 + { + /// @src 0:79:435 \"contract C...\" + let newFreePtr := add(_4, and(add(/** @src 0:410:418 \"this.f()\" */ returndatasize(), /** @src 0:79:435 \"contract C...\" */ 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(/** @src 0:410:418 \"this.f()\" */ 4, /** @src 0:79:435 \"contract C...\" */ 0x41) + revert(_2, 0x24) + } + mstore(64, newFreePtr) + /// @src 0:410:418 \"this.f()\" + expr := abi_decode_int256_fromMemory(_4, add(_4, returndatasize())) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:343:344 \"_\" + _1 := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + } + /// @src 0:79:435 \"contract C...\" + function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 + { + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } + value0 := mload(headStart) + } + } + data \".metadata\" hex\"\" + } +} "}},"D":{"D":{"ir":"/*=====================================================* * WARNING * * Solidity to Yul compilation is still EXPERIMENTAL * @@ -767,20 +968,20 @@ object \"D_72\" { } /// @ast-id 20 - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" function constructor_C_54(var__init_12) { - /// @src 0:175:223 \"constructor(int _init)...\" + /// @src 0:182:230 \"constructor(int _init)...\" - /// @src 0:147:149 \"42\" + /// @src 0:154:156 \"42\" let expr_7 := 0x2a let _6 := convert_t_rational_42_by_1_to_t_int256(expr_7) mstore(128, _6) - /// @src 0:214:219 \"_init\" + /// @src 0:221:226 \"_init\" let _7 := var__init_12 let expr_16 := _7 - /// @src 0:203:219 \"stateVar = _init\" + /// @src 0:210:226 \"stateVar = _init\" update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_16) let expr_17 := expr_16 @@ -835,6 +1036,18 @@ object \"D_72\" { return(memPos, sub(memEnd, memPos)) } + case 0xa00b982b + { + // constVar() + + if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } + abi_decode_tuple_(4, calldatasize()) + let ret_0 := getter_fun_constVar_5() + let memPos := allocate_unbounded() + let memEnd := abi_encode_tuple_t_int256__to_t_int256__fromStack(memPos , ret_0) + return(memPos, sub(memEnd, memPos)) + } + default {} } if iszero(calldatasize()) { } @@ -900,7 +1113,7 @@ object \"D_72\" { } /// @ast-id 10 - /// @src 0:152:171 \"int public stateVar\" + /// @src 0:159:178 \"int public stateVar\" function getter_fun_stateVar_10() -> ret { let slot := 0 @@ -911,14 +1124,6 @@ object \"D_72\" { } /// @src 1:91:166 \"contract D is C(3)...\" - function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { - revert(0, 0) - } - - function zero_value_for_split_t_int256() -> ret { - ret := 0 - } - function cleanup_t_rational_41_by_1(value) -> cleaned { cleaned := value } @@ -931,13 +1136,28 @@ object \"D_72\" { converted := cleanup_t_int256(identity(cleanup_t_rational_41_by_1(value))) } - /// @src 0:93:119 \"int constant constVar = 41\" + /// @src 0:93:126 \"int public constant constVar = 41\" function constant_constVar_5() -> ret { - /// @src 0:117:119 \"41\" + /// @src 0:124:126 \"41\" let expr_4 := 0x29 - let _2 := convert_t_rational_41_by_1_to_t_int256(expr_4) + let _1 := convert_t_rational_41_by_1_to_t_int256(expr_4) - ret := _2 + ret := _1 + } + + /// @ast-id 5 + /// @src 0:93:126 \"int public constant constVar = 41\" + function getter_fun_constVar_5() -> ret_0 { + ret_0 := constant_constVar_5() + } + /// @src 1:91:166 \"contract D is C(3)...\" + + function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { + revert(0, 0) + } + + function zero_value_for_split_t_int256() -> ret { + ret := 0 } function panic_error_0x11() { @@ -959,21 +1179,21 @@ object \"D_72\" { } /// @ast-id 30 - /// @src 0:226:302 \"function f() external pure returns (int)...\" + /// @src 0:233:309 \"function f() external pure returns (int)...\" function fun_f_30() -> var__23 { - /// @src 0:262:265 \"int\" - let zero_t_int256_1 := zero_value_for_split_t_int256() - var__23 := zero_t_int256_1 + /// @src 0:269:272 \"int\" + let zero_t_int256_2 := zero_value_for_split_t_int256() + var__23 := zero_t_int256_2 - /// @src 0:279:287 \"constVar\" + /// @src 0:286:294 \"constVar\" let expr_25 := constant_constVar_5() - /// @src 0:290:298 \"immutVar\" + /// @src 0:297:305 \"immutVar\" let _3 := loadimmutable(\"8\") let expr_26 := _3 - /// @src 0:279:298 \"constVar + immutVar\" + /// @src 0:286:305 \"constVar + immutVar\" let expr_27 := checked_add_t_int256(expr_25, expr_26) - /// @src 0:272:298 \"return constVar + immutVar\" + /// @src 0:279:305 \"return constVar + immutVar\" var__23 := expr_27 leave @@ -1030,16 +1250,16 @@ object \"D_72\" { } /// @ast-id 37 - /// @src 0:304:341 \"modifier m()...\" + /// @src 0:311:348 \"modifier m()...\" function modifier_m_40(var__42) -> _5 { _5 := var__42 - /// @src 0:322:332 \"stateVar++\" + /// @src 0:329:339 \"stateVar++\" let _7 := read_from_storage_split_offset_0_t_int256(0x00) let _6 := increment_t_int256(_7) update_storage_value_offset_0t_int256_to_t_int256(0x00, _6) let expr_33 := _7 - /// @src 0:336:337 \"_\" + /// @src 0:343:344 \"_\" _5 := fun_f2_53_inner(var__42) } @@ -1125,19 +1345,19 @@ object \"D_72\" { revert(pos, returndatasize()) } - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53_inner(_8) -> var__42 { var__42 := _8 - /// @src 0:392:400 \"stateVar\" + /// @src 0:399:407 \"stateVar\" let _9 := read_from_storage_split_offset_0_t_int256(0x00) let expr_44 := _9 - /// @src 0:403:407 \"this\" + /// @src 0:410:414 \"this\" let expr_45_address := address() - /// @src 0:403:409 \"this.f\" + /// @src 0:410:416 \"this.f\" let expr_46_address := convert_t_contract$_C_$54_to_t_address(expr_45_address) let expr_46_functionSelector := 0x26121ff0 - /// @src 0:403:411 \"this.f()\" + /// @src 0:410:418 \"this.f()\" if iszero(extcodesize(expr_46_address)) { revert_error_0cc013b6b3b6beabea4e3a74a6d380f0df81852ca99887912475e1f66b2a2c20() } // storage for arguments and returned data @@ -1158,16 +1378,16 @@ object \"D_72\" { // decode return parameters from external try-call into retVars expr_47 := abi_decode_tuple_t_int256_fromMemory(_10, add(_10, returndatasize())) } - /// @src 0:392:411 \"stateVar + this.f()\" + /// @src 0:399:418 \"stateVar + this.f()\" let expr_48 := checked_add_t_int256(expr_44, expr_47) - /// @src 0:414:422 \"immutVar\" + /// @src 0:421:429 \"immutVar\" let _13 := loadimmutable(\"8\") let expr_49 := _13 - /// @src 0:392:422 \"stateVar + this.f() + immutVar\" + /// @src 0:399:429 \"stateVar + this.f() + immutVar\" let expr_50 := checked_add_t_int256(expr_48, expr_49) - /// @src 0:385:422 \"return stateVar + this.f() + immutVar\" + /// @src 0:392:429 \"return stateVar + this.f() + immutVar\" var__42 := expr_50 leave @@ -1175,9 +1395,9 @@ object \"D_72\" { /// @src 1:91:166 \"contract D is C(3)...\" /// @ast-id 53 - /// @src 0:343:426 \"function f2() m public returns (int)...\" + /// @src 0:350:433 \"function f2() m public returns (int)...\" function fun_f2_53() -> var__42 { - /// @src 0:375:378 \"int\" + /// @src 0:382:385 \"int\" let zero_t_int256_4 := zero_value_for_split_t_int256() var__42 := zero_t_int256_4 @@ -1192,4 +1412,194 @@ object \"D_72\" { } +","irOptimized":"/*=====================================================* + * WARNING * + * Solidity to Yul compilation is still EXPERIMENTAL * + * It can result in LOSS OF FUNDS or worse * + * !USE AT YOUR OWN RISK! * + *=====================================================*/ + +/// @use-src 0:\"C\", 1:\"D\" +object \"D_72\" { + code { + { + /// @src 1:91:166 \"contract D is C(3)...\" + mstore(64, 160) + if callvalue() { revert(0, 0) } + let programSize := datasize(\"D_72\") + let argSize := sub(codesize(), programSize) + let newFreePtr := add(160, and(add(argSize, 31), not(31))) + if or(gt(newFreePtr, sub(shl(64, 1), 1)), lt(newFreePtr, 160)) + { + mstore(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x41) + revert(/** @src -1:-1:-1 */ 0, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + } + mstore(64, newFreePtr) + codecopy(160, programSize, argSize) + if slt(argSize, 32) + { + revert(/** @src -1:-1:-1 */ 0, 0) + } + /// @src 1:91:166 \"contract D is C(3)...\" + constructor_D(mload(160)) + let _1 := mload(64) + let _2 := datasize(\"D_72_deployed\") + codecopy(_1, dataoffset(\"D_72_deployed\"), _2) + setimmutable(_1, \"8\", mload(128)) + return(_1, _2) + } + /// @ast-id 71 @src 1:113:164 \"constructor(int _init2)...\" + function constructor_D(var_init2) + { + /// @src 0:154:156 \"42\" + mstore(128, 0x2a) + /// @src 1:91:166 \"contract D is C(3)...\" + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:107:108 \"3\" */ 0x03) + /// @src 1:91:166 \"contract D is C(3)...\" + if and(1, sgt(var_init2, sub(shl(255, 1), 4))) + { + mstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x24) + } + sstore(/** @src 0:210:226 \"stateVar = _init\" */ 0x00, /** @src 1:91:166 \"contract D is C(3)...\" */ add(/** @src 1:107:108 \"3\" */ 0x03, /** @src 1:91:166 \"contract D is C(3)...\" */ var_init2)) + } + } + /// @use-src 0:\"C\", 1:\"D\" + object \"D_72_deployed\" { + code { + { + /// @src 1:91:166 \"contract D is C(3)...\" + mstore(64, 128) + if iszero(lt(calldatasize(), 4)) + { + let _1 := 0 + switch shr(224, calldataload(_1)) + case 0x26121ff0 { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret := /** @src 0:286:305 \"constVar + immutVar\" */ checked_add_int256_568(/** @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)) + } + case 0x793816ec { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_1 := sload(_1) + let memPos_1 := mload(64) + return(memPos_1, sub(abi_encode_int256(memPos_1, ret_1), memPos_1)) + } + case 0x9942ec6f { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let ret_2 := /** @src 0:382:385 \"int\" */ modifier_m() + /// @src 1:91:166 \"contract D is C(3)...\" + let memPos_2 := mload(64) + return(memPos_2, sub(abi_encode_int256(memPos_2, ret_2), memPos_2)) + } + case 0xa00b982b { + if callvalue() { revert(_1, _1) } + abi_decode(calldatasize()) + let memPos_3 := mload(64) + return(memPos_3, sub(abi_encode_int256_567(memPos_3), memPos_3)) + } + } + revert(0, 0) + } + function abi_decode(dataEnd) + { + if slt(add(dataEnd, not(3)), 0) { revert(0, 0) } + } + function abi_encode_int256_567(headStart) -> tail + { + tail := add(headStart, 32) + mstore(headStart, /** @src 0:124:126 \"41\" */ 0x29) + } + /// @src 1:91:166 \"contract D is C(3)...\" + function abi_encode_int256(headStart, value0) -> tail + { + tail := add(headStart, 32) + mstore(headStart, value0) + } + function panic_error_0x11() + { + mstore(0, shl(224, 0x4e487b71)) + mstore(4, 0x11) + revert(0, 0x24) + } + function checked_add_int256_568(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) + } + function checked_add_int256(x, y) -> sum + { + let _1 := slt(x, 0) + if and(iszero(_1), sgt(y, sub(sub(shl(255, 1), 1), x))) { panic_error_0x11() } + if and(_1, slt(y, sub(shl(255, 1), x))) { panic_error_0x11() } + sum := add(x, y) + } + /// @ast-id 37 @src 0:311:348 \"modifier m()...\" + function modifier_m() -> _1 + { + /// @src 1:91:166 \"contract D is C(3)...\" + let _2 := 0 + let _3 := sload(_2) + if eq(_3, sub(shl(255, 1), 1)) { panic_error_0x11() } + 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)) + /// @src 0:410:418 \"this.f()\" + let _5 := staticcall(gas(), /** @src 0:410:414 \"this\" */ address(), /** @src 0:410:418 \"this.f()\" */ _4, 4, _4, 32) + if iszero(_5) + { + /// @src 1:91:166 \"contract D is C(3)...\" + let pos := mload(64) + returndatacopy(pos, _2, returndatasize()) + revert(pos, returndatasize()) + } + /// @src 0:410:418 \"this.f()\" + let expr := /** @src 1:91:166 \"contract D is C(3)...\" */ _2 + /// @src 0:410:418 \"this.f()\" + if _5 + { + /// @src 1:91:166 \"contract D is C(3)...\" + let newFreePtr := add(_4, and(add(/** @src 0:410:418 \"this.f()\" */ returndatasize(), /** @src 1:91:166 \"contract D is C(3)...\" */ 31), not(31))) + if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, _4)) + { + mstore(_2, shl(224, 0x4e487b71)) + mstore(/** @src 0:410:418 \"this.f()\" */ 4, /** @src 1:91:166 \"contract D is C(3)...\" */ 0x41) + revert(_2, 0x24) + } + mstore(64, newFreePtr) + /// @src 0:410:418 \"this.f()\" + expr := abi_decode_int256_fromMemory(_4, add(_4, returndatasize())) + } + /// @src 0:399:418 \"stateVar + this.f()\" + let expr_1 := checked_add_int256(ret, expr) + /// @src 0:343:344 \"_\" + _1 := /** @src 0:399:429 \"stateVar + this.f() + immutVar\" */ checked_add_int256(expr_1, /** @src 0:421:429 \"immutVar\" */ loadimmutable(\"8\")) + } + /// @src 1:91:166 \"contract D is C(3)...\" + function abi_decode_int256_fromMemory(headStart, dataEnd) -> value0 + { + if slt(sub(dataEnd, headStart), 32) { revert(0, 0) } + value0 := mload(headStart) + } + } + data \".metadata\" hex\"\" + } +} "}}},"sources":{"C":{"id":0},"D":{"id":1}}}