diff --git a/test/cmdlineTests/constant_optimizer_yul/output b/test/cmdlineTests/constant_optimizer_yul/output index 9a125bd36..0aa214920 100644 --- a/test/cmdlineTests/constant_optimizer_yul/output +++ b/test/cmdlineTests/constant_optimizer_yul/output @@ -10,19 +10,25 @@ object "C_12" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } - sstore(0, shl(180, 1)) + if callvalue() + { + revert(returndatasize(), returndatasize()) + } + sstore(returndatasize(), shl(180, 1)) let _1 := datasize("C_12_deployed") - codecopy(0, dataoffset("C_12_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_12_deployed"), _1) + return(returndatasize(), _1) } } object "C_12_deployed" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } - sstore(0, 0x1000000000000000000000000000000000000000000000) + if callvalue() + { + revert(returndatasize(), returndatasize()) + } + sstore(returndatasize(), 0x1000000000000000000000000000000000000000000000) stop() } } diff --git a/test/cmdlineTests/evm_to_wasm/output b/test/cmdlineTests/evm_to_wasm/output index fa454f80f..68dbeb22c 100644 --- a/test/cmdlineTests/evm_to_wasm/output +++ b/test/cmdlineTests/evm_to_wasm/output @@ -3,7 +3,9 @@ Pretty printed source: object "object" { - code { { sstore(0, 1) } } + code { + { sstore(returndatasize(), 1) } + } } @@ -14,17 +16,20 @@ object "object" { code { function main() { - let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) - let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) + let _1 := i64.extend_i32_u(eth.getReturnDataSize()) + let _2 := 32 + let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), _2) + let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, _2))))) i64.store(0:i32, y) i64.store(i32.add(0:i32, 8:i32), y) i64.store(i32.add(0:i32, 16:i32), y) - i64.store(i32.add(0:i32, 24:i32), y) + let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(_1))), _2) + i64.store(i32.add(0:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(_1, _2)))))) i64.store(32:i32, y) i64.store(i32.add(32:i32, 8:i32), y) i64.store(i32.add(32:i32, 16:i32), y) - let hi_1 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(1))), 32) - i64.store(i32.add(32:i32, 24:i32), i64.or(hi_1, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(1, 32)))))) + let hi_2 := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(1))), _2) + i64.store(i32.add(32:i32, 24:i32), i64.or(hi_2, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(1, _2)))))) eth.storageStore(0:i32, 32:i32) } function bswap16(x:i32) -> y:i32 @@ -41,30 +46,37 @@ object "object" { Binary representation: -0061736d01000000010e0360000060017f017f60027f7f0002190108657468657265756d0c73746f7261676553746f726500020304030001010503010001060100071102066d656d6f72790200046d61696e00010ac70103850101037e02404200a71003ad422086210020004200422088a71003ad84210141002001370000410041086a2001370000410041106a2001370000410041186a200137000041202001370000412041086a2001370000412041106a20013700004201a71003ad4220862102412041186a20024201422088a71003ad843700004100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100241107421022002200041107610027221010b20010b +0061736d010000000112046000006000017f60017f017f60027f7f0002360208657468657265756d0c73746f7261676553746f7265000308657468657265756d1167657452657475726e4461746153697a6500010304030002020503010001060100071102066d656d6f72790200046d61696e00020ae50103a30101067e02401001ad2100422021014200a71004ad200186210220024200200188a71004ad84210341002003370000410041086a2003370000410041106a20033700002000a71004ad2001862104410041186a20042000200188a71004ad8437000041202003370000412041086a2003370000412041106a20033700004201a71004ad2001862105412041186a20054201200188a71004ad843700004100412010000b0b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100341107421022002200041107610037221010b20010b Text representation: (module (import "ethereum" "storageStore" (func $eth.storageStore (param i32 i32))) + (import "ethereum" "getReturnDataSize" (func $eth.getReturnDataSize (result i32))) (memory $memory (export "memory") 1) (export "main" (func $main)) (func $main + (local $_1 i64) + (local $_2 i64) (local $hi i64) (local $y i64) (local $hi_1 i64) + (local $hi_2 i64) (block $label_ - (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) + (local.set $_1 (i64.extend_i32_u (call $eth.getReturnDataSize))) + (local.set $_2 (i64.const 32)) + (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (local.get $_2))) + (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (local.get $_2))))))) (i64.store (i32.const 0) (local.get $y)) (i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y)) (i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y)) - (i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y)) + (local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $_1)))) (local.get $_2))) + (i64.store (i32.add (i32.const 0) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $_1) (local.get $_2))))))) (i64.store (i32.const 32) (local.get $y)) (i64.store (i32.add (i32.const 32) (i32.const 8)) (local.get $y)) (i64.store (i32.add (i32.const 32) (i32.const 16)) (local.get $y)) - (local.set $hi_1 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 1)))) (i64.const 32))) - (i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_1) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 1) (i64.const 32))))))) + (local.set $hi_2 (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 1)))) (local.get $_2))) + (i64.store (i32.add (i32.const 32) (i32.const 24)) (i64.or (local.get $hi_2) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 1) (local.get $_2))))))) (call $eth.storageStore (i32.const 0) (i32.const 32)) ) ) diff --git a/test/cmdlineTests/evm_to_wasm_break/output b/test/cmdlineTests/evm_to_wasm_break/output index 0eaf827d2..f8416fc16 100644 --- a/test/cmdlineTests/evm_to_wasm_break/output +++ b/test/cmdlineTests/evm_to_wasm_break/output @@ -5,13 +5,13 @@ Pretty printed source: object "object" { code { { - let x := calldataload(0) + let x := calldataload(returndatasize()) for { } lt(x, 10) { x := add(x, 1) } { if eq(x, 2) { break } if eq(x, 4) { continue } } - sstore(0, x) + sstore(returndatasize(), x) } } } @@ -24,14 +24,15 @@ object "object" { code { function main() { - let x, x_1, x_2, x_3 := calldataload() + let _1, _2, _3, _4 := returndatasize_1183() + let x, x_1, x_2, x_3 := calldataload(_1, _2, _3, _4) let x_4 := x let x_5 := x_1 let x_6 := x_2 let x_7 := x_3 - let _1:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, 1))))) + let _5:i32 := i32.eqz(i32.eqz(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, 1))))) for { } - i32.eqz(_1) + i32.eqz(_5) { let x_8, x_9, x_10, x_11 := add(x_4, x_5, x_6, x_7) x_4 := x_8 @@ -40,14 +41,15 @@ object "object" { x_7 := x_11 } { - let _2, _3, _4, _5 := iszero_1300_2121(lt(x_4, x_5, x_6, x_7)) - if i32.eqz(i64.eqz(i64.or(i64.or(_2, _3), i64.or(_4, _5)))) { break } - let _6, _7, _8, _9 := eq_740_2122(x_4, x_5, x_6, x_7) + let _6, _7, _8, _9 := iszero_1179(lt(x_4, x_5, x_6, x_7)) if i32.eqz(i64.eqz(i64.or(i64.or(_6, _7), i64.or(_8, _9)))) { break } - let _10, _11, _12, _13 := eq_741_2123(x_4, x_5, x_6, x_7) - if i32.eqz(i64.eqz(i64.or(i64.or(_10, _11), i64.or(_12, _13)))) { continue } + let _10, _11, _12, _13 := eq_734(x_4, x_5, x_6, x_7) + if i32.eqz(i64.eqz(i64.or(i64.or(_10, _11), i64.or(_12, _13)))) { break } + let _14, _15, _16, _17 := eq_735(x_4, x_5, x_6, x_7) + if i32.eqz(i64.eqz(i64.or(i64.or(_14, _15), i64.or(_16, _17)))) { continue } } - sstore(x_4, x_5, x_6, x_7) + let _18, _19, _20, _21 := returndatasize_1183() + sstore(_18, _19, _20, _21, x_4, x_5, x_6, x_7) } function add(x1, x2, x3, x4) -> r1, r2, r3, r4 { @@ -59,15 +61,15 @@ object "object" { r2 := i64.add(t_2, i64.extend_i32_u(i32.or(i64.lt_u(t_1, x3), i64.lt_u(r3, t_1)))) r1 := i64.add(i64.add(x1, 0), i64.extend_i32_u(i32.or(i64.lt_u(t_2, x2), i64.lt_u(r2, t_2)))) } - function iszero_1300_2121(x4) -> r1, r2, r3, r4 + function iszero_1179(x4) -> r1, r2, r3, r4 { r4 := i64.extend_i32_u(i64.eqz(i64.or(i64.or(0, 0), i64.or(0, x4)))) } - function eq_740_2122(x1, x2, x3, x4) -> r1, r2, r3, r4 + function eq_734(x1, x2, x3, x4) -> r1, r2, r3, r4 { r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 2))))) } - function eq_741_2123(x1, x2, x3, x4) -> r1, r2, r3, r4 + function eq_735(x1, x2, x3, x4) -> r1, r2, r3, r4 { r4 := i64.extend_i32_u(i32.and(i64.eq(x1, 0), i32.and(i64.eq(x2, 0), i32.and(i64.eq(x3, 0), i64.eq(x4, 4))))) } @@ -92,18 +94,17 @@ object "object" { default { z := 1:i32 } z4 := i64.extend_i32_u(z) } - function u256_to_i32_744() -> v:i32 + function u256_to_i32_737() -> v:i32 { if i64.ne(0, i64.or(i64.or(0, 0), 0)) { unreachable() } if i64.ne(0, i64.shr_u(32, 32)) { unreachable() } v := i32.wrap_i64(32) } - function u256_to_i32() -> v:i32 + function u256_to_i32(x1, x2, x3, x4) -> v:i32 { - let _1 := 0 - if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() } - if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() } - v := i32.wrap_i64(_1) + if i64.ne(0, i64.or(i64.or(x1, x2), x3)) { unreachable() } + if i64.ne(0, i64.shr_u(x4, 32)) { unreachable() } + v := i32.wrap_i64(x4) } function bswap16(x:i32) -> y:i32 { @@ -119,15 +120,15 @@ object "object" { let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(x))), 32) y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(x, 32))))) } - function calldataload() -> z1, z2, z3, z4 + function calldataload(x1, x2, x3, x4) -> z1, z2, z3, z4 { let cds:i32 := eth.getCallDataSize() let _1 := 0 if i64.ne(_1, i64.or(i64.or(_1, _1), _1)) { unreachable() } if i64.ne(_1, i64.shr_u(_1, 32)) { unreachable() } let v:i32 := i32.wrap_i64(_1) - let offset:i32 := u256_to_i32() - let requested_size:i32 := u256_to_i32_744() + let offset:i32 := u256_to_i32(x1, x2, x3, x4) + let requested_size:i32 := u256_to_i32_737() if i32.gt_u(offset, i32.sub(0xffffffff:i32, requested_size)) { eth.revert(0:i32, 0:i32) } let available_size:i32 := i32.sub(cds, offset) if i32.gt_u(offset, cds) { available_size := 0:i32 } @@ -152,14 +153,16 @@ object "object" { z3 := z3_1 z4 := z4_1 } - function sstore(y1, y2, y3, y4) + function returndatasize_1183() -> z1, z2, z3, z4 { - let hi := i64.shl(i64.extend_i32_u(bswap32(i32.wrap_i64(0))), 32) - let y := i64.or(hi, i64.extend_i32_u(bswap32(i32.wrap_i64(i64.shr_u(0, 32))))) - i64.store(0:i32, y) - i64.store(i32.add(0:i32, 8:i32), y) - i64.store(i32.add(0:i32, 16:i32), y) - i64.store(i32.add(0:i32, 24:i32), y) + z4 := i64.extend_i32_u(eth.getReturnDataSize()) + } + function sstore(x1, x2, x3, x4, y1, y2, y3, y4) + { + i64.store(0:i32, bswap64(x1)) + i64.store(i32.add(0:i32, 8:i32), bswap64(x2)) + i64.store(i32.add(0:i32, 16:i32), bswap64(x3)) + i64.store(i32.add(0:i32, 24:i32), bswap64(x4)) i64.store(32:i32, bswap64(y1)) i64.store(i32.add(32:i32, 8:i32), bswap64(y2)) i64.store(i32.add(32:i32, 16:i32), bswap64(y3)) @@ -178,7 +181,7 @@ object "object" { Binary representation: -0061736d010000000130096000006000017e6000017f60017e017e60047e7e7e7e0060047e7e7e7e017e60017f017f60027f7f0060037f7f7f00025e0408657468657265756d0c73746f7261676553746f7265000708657468657265756d06726576657274000708657468657265756d0f67657443616c6c4461746153697a65000208657468657265756d0c63616c6c44617461436f70790008030f0e00050305050502020606030104010503010001061a057e0142000b7e0142000b7e0142000b7f0141000b7f0141000b071102066d656d6f72790200046d61696e00040a8a0a0e8d0203087e017f107e02400240100f21002300210123012102230221030b200021042001210520022106200321074200420084420042018484504545210802400340200845450d010240024020042005200620071009100621092303210a2304210b2300210c0b2009200a84200b200c8484504504400c030b024020042005200620071007210d2300210e2301210f230221100b200d200e84200f20108484504504400c030b02402004200520062007100821112300211223012113230221140b2011201284201320148484504504400c010b0b02402004200520062007100521152300211623012117230221180b201521042016210520172106201821070c000b0b200420052006200710100b0b6701077e0240200342017c2108200842007c2107200242007c210920092008200354200720085472ad7c2106200142007c210a200a2009200254200620095472ad7c2105200042007c200a2001542005200a5472ad7c21040b20052400200624012007240220040b2401047e0240420042008442002000848450ad21040b20022400200324012004240220010b2f01047e02402000420051200142005120024200512003420251717171ad21070b20052400200624012007240220040b2f01047e02402000420051200142005120024200512003420451717171ad21070b20052400200624012007240220040bab0104017e017f017e047f02404100210542002106417f210702402007200020065220002006541b21082008410046044002402007200120065220012006541b21092009410046044002402007200220065220022006541b210a200a41004604402003420a54210505200a41014604404100210505410121050b0b0b05200941014604404100210505410121050b0b0b05200841014604404100210505410121050b0b0b2005ad21040b20040b2901017f024042004200420084420084520440000b42004220422088520440000b4220a721000b20000b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100c411074210220022000411076100c7221010b20010b2201027e02402000a7100dad422086210220022000422088a7100dad8421010b20010be60105047e017f017e087f047e0240100221044200210520052005200584200584520440000b20052005422088520440000b2005a72106100b2107100a21082007417f20086b4b04404100410010010b200420076b2109200720044b0440410021090b4100210a2009200a4b044020062007200910030b200820094b0440200820096b210b200620096a210c200a210d02400340200d200b49450d010240200c200d6a200a3a00000b200d41016a210d0c000b0b0b02401011210e2300210f23012110230221110b200e2100200f210120102102201121030b20012400200224012003240220000b7801027e02404200a7100dad422086210420044200422088a7100dad84210541002005370000410041086a2005370000410041106a2005370000410041186a200537000041202000100e370000412041086a2001100e370000412041106a2002100e370000412041186a2003100e3700004100412010000b0b4201047e02404100290000100e2100410041086a290000100e2101410041106a290000100e2102410041186a290000100e21030b20012400200224012003240220000b +0061736d01000000013c0a6000006000017e6000017f60017e017e60047e7e7e7e017e60047e7e7e7e017f60087e7e7e7e7e7e7e7e0060017f017f60027f7f0060037f7f7f00027b0508657468657265756d0c73746f7261676553746f7265000808657468657265756d06726576657274000808657468657265756d0f67657443616c6c4461746153697a65000208657468657265756d0c63616c6c44617461436f7079000908657468657265756d1167657452657475726e4461746153697a65000203100f0004030404040205070703040106010503010001061f067f0141000b7f0141000b7f0141000b7e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e00050aca0a0fc302030c7e017f147e02400240101121002300210123012102230221030b02402000200120022003101021042303210523042106230521070b20042108200521092006210a2007210b4200420084420042018484504545210c02400340200c45450d010240024020082009200a200b100a1007210d2303210e2304210f230521100b200d200e84200f20108484504504400c030b024020082009200a200b100821112303211223042113230521140b2011201284201320148484504504400c030b024020082009200a200b100921152303211623042117230521180b2015201684201720188484504504400c010b0b024020082009200a200b100621192303211a2304211b2305211c0b20192108201a2109201b210a201c210b0c000b0b02401011211d2303211e2304211f230521200b201d201e201f202020082009200a200b10120b0b6701077e0240200342017c2108200842007c2107200242007c210920092008200354200720085472ad7c2106200142007c210a200a2009200254200620095472ad7c2105200042007c200a2001542005200a5472ad7c21040b20052403200624042007240520040b2401047e0240420042008442002000848450ad21040b20022403200324042004240520010b2f01047e02402000420051200142005120024200512003420251717171ad21070b20052403200624042007240520040b2f01047e02402000420051200142005120024200512003420451717171ad21070b20052403200624042007240520040bab0104017e017f017e047f02404100210542002106417f210702402007200020065220002006541b21082008410046044002402007200120065220012006541b21092009410046044002402007200220065220022006541b210a200a41004604402003420a54210505200a41014604404100210505410121050b0b0b05200941014604404100210505410121050b0b0b05200841014604404100210505410121050b0b0b2005ad21040b20040b2901017f024042004200420084420084520440000b42004220422088520440000b4220a721000b20000b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100d411074210220022000411076100d7221010b20010b2201027e02402000a7100ead422086210220022000422088a7100ead8421010b20010bee0105047e017f017e087f047e0240100221084200210920092009200984200984520440000b20092009422088520440000b2009a7210a2000200120022003100c210b100b210c200b417f200c6b4b04404100410010010b2008200b6b210d200b20084b04404100210d0b4100210e200d200e4b0440200a200b200d10030b200c200d4b0440200c200d6b210f200a200d6a2110200e2111024003402011200f49450d010240201020116a200e3a00000b201141016a21110c000b0b0b0240101321122303211323042114230521150b201221042013210520142106201521070b20052403200624042007240520040b1a01047e02401004ad21030b20012403200224042003240520000b6500024041002000100f370000410041086a2001100f370000410041106a2002100f370000410041186a2003100f37000041202004100f370000412041086a2005100f370000412041106a2006100f370000412041186a2007100f3700004100412010000b0b4201047e02404100290000100f2100410041086a290000100f2101410041106a290000100f2102410041186a290000100f21030b20012403200224042003240520000b Text representation: (module @@ -186,15 +189,21 @@ Text representation: (import "ethereum" "revert" (func $eth.revert (param i32 i32))) (import "ethereum" "getCallDataSize" (func $eth.getCallDataSize (result i32))) (import "ethereum" "callDataCopy" (func $eth.callDataCopy (param i32 i32 i32))) + (import "ethereum" "getReturnDataSize" (func $eth.getReturnDataSize (result i32))) (memory $memory (export "memory") 1) (export "main" (func $main)) - (global $global_ (mut i64) (i64.const 0)) - (global $global__1 (mut i64) (i64.const 0)) - (global $global__2 (mut i64) (i64.const 0)) - (global $global__6 (mut i32) (i32.const 0)) - (global $global__7 (mut i32) (i32.const 0)) + (global $global_ (mut i32) (i32.const 0)) + (global $global__1 (mut i32) (i32.const 0)) + (global $global__2 (mut i32) (i32.const 0)) + (global $global__3 (mut i64) (i64.const 0)) + (global $global__4 (mut i64) (i64.const 0)) + (global $global__5 (mut i64) (i64.const 0)) (func $main + (local $_1 i64) + (local $_2 i64) + (local $_3 i64) + (local $_4 i64) (local $x i64) (local $x_1 i64) (local $x_2 i64) @@ -203,11 +212,7 @@ Text representation: (local $x_5 i64) (local $x_6 i64) (local $x_7 i64) - (local $_1 i32) - (local $_2 i64) - (local $_3 i64) - (local $_4 i64) - (local $_5 i64) + (local $_5 i32) (local $_6 i64) (local $_7 i64) (local $_8 i64) @@ -216,75 +221,97 @@ Text representation: (local $_11 i64) (local $_12 i64) (local $_13 i64) + (local $_14 i64) + (local $_15 i64) + (local $_16 i64) + (local $_17 i64) (local $x_8 i64) (local $x_9 i64) (local $x_10 i64) (local $x_11 i64) + (local $_18 i64) + (local $_19 i64) + (local $_20 i64) + (local $_21 i64) (block $label_ (block - (local.set $x (call $calldataload)) - (local.set $x_1 (global.get $global_)) - (local.set $x_2 (global.get $global__1)) - (local.set $x_3 (global.get $global__2)) + (local.set $_1 (call $returndatasize_1183)) + (local.set $_2 (global.get $global_)) + (local.set $_3 (global.get $global__1)) + (local.set $_4 (global.get $global__2)) + + ) + (block + (local.set $x (call $calldataload (local.get $_1) (local.get $_2) (local.get $_3) (local.get $_4))) + (local.set $x_1 (global.get $global__3)) + (local.set $x_2 (global.get $global__4)) + (local.set $x_3 (global.get $global__5)) ) (local.set $x_4 (local.get $x)) (local.set $x_5 (local.get $x_1)) (local.set $x_6 (local.get $x_2)) (local.set $x_7 (local.get $x_3)) - (local.set $_1 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (i64.const 1))))))) - (block $label__3 - (loop $label__5 - (br_if $label__3 (i32.eqz (i32.eqz (local.get $_1)))) - (block $label__4 + (local.set $_5 (i32.eqz (i32.eqz (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (i64.const 1))))))) + (block $label__6 + (loop $label__8 + (br_if $label__6 (i32.eqz (i32.eqz (local.get $_5)))) + (block $label__7 (block - (local.set $_2 (call $iszero_1300_2121 (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))) - (local.set $_3 (global.get $global__6)) - (local.set $_4 (global.get $global__7)) - (local.set $_5 (global.get $global_)) - - ) - (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_2) (local.get $_3)) (i64.or (local.get $_4) (local.get $_5))))) (then - (br $label__3) - )) - (block - (local.set $_6 (call $eq_740_2122 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) - (local.set $_7 (global.get $global_)) - (local.set $_8 (global.get $global__1)) - (local.set $_9 (global.get $global__2)) + (local.set $_6 (call $iszero_1179 (call $lt (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)))) + (local.set $_7 (global.get $global__3)) + (local.set $_8 (global.get $global__4)) + (local.set $_9 (global.get $global__5)) ) (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_6) (local.get $_7)) (i64.or (local.get $_8) (local.get $_9))))) (then - (br $label__3) + (br $label__6) )) (block - (local.set $_10 (call $eq_741_2123 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) - (local.set $_11 (global.get $global_)) - (local.set $_12 (global.get $global__1)) - (local.set $_13 (global.get $global__2)) + (local.set $_10 (call $eq_734 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) + (local.set $_11 (global.get $global__3)) + (local.set $_12 (global.get $global__4)) + (local.set $_13 (global.get $global__5)) ) (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_10) (local.get $_11)) (i64.or (local.get $_12) (local.get $_13))))) (then - (br $label__4) + (br $label__6) + )) + (block + (local.set $_14 (call $eq_735 (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) + (local.set $_15 (global.get $global__3)) + (local.set $_16 (global.get $global__4)) + (local.set $_17 (global.get $global__5)) + + ) + (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $_14) (local.get $_15)) (i64.or (local.get $_16) (local.get $_17))))) (then + (br $label__7) )) ) (block (local.set $x_8 (call $add (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7))) - (local.set $x_9 (global.get $global_)) - (local.set $x_10 (global.get $global__1)) - (local.set $x_11 (global.get $global__2)) + (local.set $x_9 (global.get $global__3)) + (local.set $x_10 (global.get $global__4)) + (local.set $x_11 (global.get $global__5)) ) (local.set $x_4 (local.get $x_8)) (local.set $x_5 (local.get $x_9)) (local.set $x_6 (local.get $x_10)) (local.set $x_7 (local.get $x_11)) - (br $label__5) + (br $label__8) ) ) - (call $sstore (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)) + (block + (local.set $_18 (call $returndatasize_1183)) + (local.set $_19 (global.get $global__3)) + (local.set $_20 (global.get $global__4)) + (local.set $_21 (global.get $global__5)) + + ) + (call $sstore (local.get $_18) (local.get $_19) (local.get $_20) (local.get $_21) (local.get $x_4) (local.get $x_5) (local.get $x_6) (local.get $x_7)) ) ) @@ -301,7 +328,7 @@ Text representation: (local $t i64) (local $t_1 i64) (local $t_2 i64) - (block $label__8 + (block $label__9 (local.set $t (i64.add (local.get $x4) (i64.const 1))) (local.set $r4 (i64.add (local.get $t) (i64.const 0))) (local.set $t_1 (i64.add (local.get $x3) (i64.const 0))) @@ -311,33 +338,13 @@ Text representation: (local.set $r1 (i64.add (i64.add (local.get $x1) (i64.const 0)) (i64.extend_i32_u (i32.or (i64.lt_u (local.get $t_2) (local.get $x2)) (i64.lt_u (local.get $r2) (local.get $t_2)))))) ) - (global.set $global_ (local.get $r2)) - (global.set $global__1 (local.get $r3)) - (global.set $global__2 (local.get $r4)) + (global.set $global__3 (local.get $r2)) + (global.set $global__4 (local.get $r3)) + (global.set $global__5 (local.get $r4)) (local.get $r1) ) -(func $iszero_1300_2121 - (param $x4 i64) - (result i64) - (local $r1 i64) - (local $r2 i64) - (local $r3 i64) - (local $r4 i64) - (block $label__9 - (local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (local.get $x4)))))) - - ) - (global.set $global_ (local.get $r2)) - (global.set $global__1 (local.get $r3)) - (global.set $global__2 (local.get $r4)) - (local.get $r1) -) - -(func $eq_740_2122 - (param $x1 i64) - (param $x2 i64) - (param $x3 i64) +(func $iszero_1179 (param $x4 i64) (result i64) (local $r1 i64) @@ -345,16 +352,16 @@ Text representation: (local $r3 i64) (local $r4 i64) (block $label__10 - (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 2))))))) + (local.set $r4 (i64.extend_i32_u (i64.eqz (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.or (i64.const 0) (local.get $x4)))))) ) - (global.set $global_ (local.get $r2)) - (global.set $global__1 (local.get $r3)) - (global.set $global__2 (local.get $r4)) + (global.set $global__3 (local.get $r2)) + (global.set $global__4 (local.get $r3)) + (global.set $global__5 (local.get $r4)) (local.get $r1) ) -(func $eq_741_2123 +(func $eq_734 (param $x1 i64) (param $x2 i64) (param $x3 i64) @@ -365,12 +372,32 @@ Text representation: (local $r3 i64) (local $r4 i64) (block $label__11 + (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 2))))))) + + ) + (global.set $global__3 (local.get $r2)) + (global.set $global__4 (local.get $r3)) + (global.set $global__5 (local.get $r4)) + (local.get $r1) +) + +(func $eq_735 + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i64) + (local $r1 i64) + (local $r2 i64) + (local $r3 i64) + (local $r4 i64) + (block $label__12 (local.set $r4 (i64.extend_i32_u (i32.and (i64.eq (local.get $x1) (i64.const 0)) (i32.and (i64.eq (local.get $x2) (i64.const 0)) (i32.and (i64.eq (local.get $x3) (i64.const 0)) (i64.eq (local.get $x4) (i64.const 4))))))) ) - (global.set $global_ (local.get $r2)) - (global.set $global__1 (local.get $r3)) - (global.set $global__2 (local.get $r4)) + (global.set $global__3 (local.get $r2)) + (global.set $global__4 (local.get $r3)) + (global.set $global__5 (local.get $r4)) (local.get $r1) ) @@ -385,9 +412,9 @@ Text representation: (local $_1 i64) (local $_2 i32) (local $condition i32) - (local $condition_13 i32) (local $condition_14 i32) - (block $label__12 + (local $condition_15 i32) + (block $label__13 (local.set $z (i32.const 0)) (local.set $_1 (i64.const 0)) (local.set $_2 (i32.const 4294967295)) @@ -395,14 +422,14 @@ Text representation: (local.set $condition (select (local.get $_2) (i64.ne (local.get $x1) (local.get $_1)) (i64.lt_u (local.get $x1) (local.get $_1)))) (if (i32.eq (local.get $condition) (i32.const 0)) (then (block - (local.set $condition_13 (select (local.get $_2) (i64.ne (local.get $x2) (local.get $_1)) (i64.lt_u (local.get $x2) (local.get $_1)))) - (if (i32.eq (local.get $condition_13) (i32.const 0)) (then + (local.set $condition_14 (select (local.get $_2) (i64.ne (local.get $x2) (local.get $_1)) (i64.lt_u (local.get $x2) (local.get $_1)))) + (if (i32.eq (local.get $condition_14) (i32.const 0)) (then (block - (local.set $condition_14 (select (local.get $_2) (i64.ne (local.get $x3) (local.get $_1)) (i64.lt_u (local.get $x3) (local.get $_1)))) - (if (i32.eq (local.get $condition_14) (i32.const 0)) (then + (local.set $condition_15 (select (local.get $_2) (i64.ne (local.get $x3) (local.get $_1)) (i64.lt_u (local.get $x3) (local.get $_1)))) + (if (i32.eq (local.get $condition_15) (i32.const 0)) (then (local.set $z (i64.lt_u (local.get $x4) (i64.const 10))) )(else - (if (i32.eq (local.get $condition_14) (i32.const 1)) (then + (if (i32.eq (local.get $condition_15) (i32.const 1)) (then (local.set $z (i32.const 0)) )(else (local.set $z (i32.const 1)) @@ -411,7 +438,7 @@ Text representation: ) )(else - (if (i32.eq (local.get $condition_13) (i32.const 1)) (then + (if (i32.eq (local.get $condition_14) (i32.const 1)) (then (local.set $z (i32.const 0)) )(else (local.set $z (i32.const 1)) @@ -434,10 +461,10 @@ Text representation: (local.get $z4) ) -(func $u256_to_i32_744 +(func $u256_to_i32_737 (result i32) (local $v i32) - (block $label__15 + (block $label__16 (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then (unreachable))) (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 32) (i64.const 32))) (then @@ -449,16 +476,18 @@ Text representation: ) (func $u256_to_i32 + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (result i32) (local $v i32) - (local $_1 i64) - (block $label__16 - (local.set $_1 (i64.const 0)) - (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then + (block $label__17 + (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then (unreachable))) - (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then + (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then (unreachable))) - (local.set $v (i32.wrap_i64 (local.get $_1))) + (local.set $v (i32.wrap_i64 (local.get $x4))) ) (local.get $v) @@ -468,7 +497,7 @@ Text representation: (param $x i32) (result i32) (local $y i32) - (block $label__17 + (block $label__18 (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) ) @@ -480,7 +509,7 @@ Text representation: (result i32) (local $y i32) (local $hi i32) - (block $label__18 + (block $label__19 (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) @@ -493,7 +522,7 @@ Text representation: (result i64) (local $y i64) (local $hi i64) - (block $label__19 + (block $label__20 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) @@ -502,6 +531,10 @@ Text representation: ) (func $calldataload + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (result i64) (local $z1 i64) (local $z2 i64) @@ -521,7 +554,7 @@ Text representation: (local $z2_1 i64) (local $z3_1 i64) (local $z4_1 i64) - (block $label__20 + (block $label__21 (local.set $cds (call $eth.getCallDataSize)) (local.set $_1 (i64.const 0)) (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then @@ -529,8 +562,8 @@ Text representation: (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then (unreachable))) (local.set $v (i32.wrap_i64 (local.get $_1))) - (local.set $offset (call $u256_to_i32)) - (local.set $requested_size (call $u256_to_i32_744)) + (local.set $offset (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))) + (local.set $requested_size (call $u256_to_i32_737)) (if (i32.gt_u (local.get $offset) (i32.sub (i32.const 4294967295) (local.get $requested_size))) (then (call $eth.revert (i32.const 0) (i32.const 0)))) (local.set $available_size (i32.sub (local.get $cds) (local.get $offset))) @@ -544,23 +577,23 @@ Text representation: (local.set $_3 (i32.sub (local.get $requested_size) (local.get $available_size))) (local.set $_4 (i32.add (local.get $v) (local.get $available_size))) (local.set $i (local.get $_2)) - (block $label__21 - (loop $label__23 - (br_if $label__21 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3)))) - (block $label__22 + (block $label__22 + (loop $label__24 + (br_if $label__22 (i32.eqz (i32.lt_u (local.get $i) (local.get $_3)))) + (block $label__23 (i32.store8 (i32.add (local.get $_4) (local.get $i)) (local.get $_2)) ) (local.set $i (i32.add (local.get $i) (i32.const 1))) - (br $label__23) + (br $label__24) ) ) )) (block (local.set $z1_1 (call $mload_internal)) - (local.set $z2_1 (global.get $global_)) - (local.set $z3_1 (global.get $global__1)) - (local.set $z4_1 (global.get $global__2)) + (local.set $z2_1 (global.get $global__3)) + (local.set $z3_1 (global.get $global__4)) + (local.set $z4_1 (global.get $global__5)) ) (local.set $z1 (local.get $z1_1)) @@ -569,26 +602,42 @@ Text representation: (local.set $z4 (local.get $z4_1)) ) - (global.set $global_ (local.get $z2)) - (global.set $global__1 (local.get $z3)) - (global.set $global__2 (local.get $z4)) + (global.set $global__3 (local.get $z2)) + (global.set $global__4 (local.get $z3)) + (global.set $global__5 (local.get $z4)) + (local.get $z1) +) + +(func $returndatasize_1183 + (result i64) + (local $z1 i64) + (local $z2 i64) + (local $z3 i64) + (local $z4 i64) + (block $label__25 + (local.set $z4 (i64.extend_i32_u (call $eth.getReturnDataSize))) + + ) + (global.set $global__3 (local.get $z2)) + (global.set $global__4 (local.get $z3)) + (global.set $global__5 (local.get $z4)) (local.get $z1) ) (func $sstore + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (param $y1 i64) (param $y2 i64) (param $y3 i64) (param $y4 i64) - (local $hi i64) - (local $y i64) - (block $label__24 - (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) - (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) - (i64.store (i32.const 0) (local.get $y)) - (i64.store (i32.add (i32.const 0) (i32.const 8)) (local.get $y)) - (i64.store (i32.add (i32.const 0) (i32.const 16)) (local.get $y)) - (i64.store (i32.add (i32.const 0) (i32.const 24)) (local.get $y)) + (block $label__26 + (i64.store (i32.const 0) (call $bswap64 (local.get $x1))) + (i64.store (i32.add (i32.const 0) (i32.const 8)) (call $bswap64 (local.get $x2))) + (i64.store (i32.add (i32.const 0) (i32.const 16)) (call $bswap64 (local.get $x3))) + (i64.store (i32.add (i32.const 0) (i32.const 24)) (call $bswap64 (local.get $x4))) (i64.store (i32.const 32) (call $bswap64 (local.get $y1))) (i64.store (i32.add (i32.const 32) (i32.const 8)) (call $bswap64 (local.get $y2))) (i64.store (i32.add (i32.const 32) (i32.const 16)) (call $bswap64 (local.get $y3))) @@ -603,16 +652,16 @@ Text representation: (local $z2 i64) (local $z3 i64) (local $z4 i64) - (block $label__25 + (block $label__27 (local.set $z1 (call $bswap64 (i64.load (i32.const 0)))) (local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8))))) (local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16))))) (local.set $z4 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24))))) ) - (global.set $global_ (local.get $z2)) - (global.set $global__1 (local.get $z3)) - (global.set $global__2 (local.get $z4)) + (global.set $global__3 (local.get $z2)) + (global.set $global__4 (local.get $z3)) + (global.set $global__5 (local.get $z4)) (local.get $z1) ) diff --git a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output index 418676634..db0b1c344 100644 --- a/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output +++ b/test/cmdlineTests/ir_compiler_inheritance_nosubobjects/output @@ -10,17 +10,20 @@ object "C_7" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_7_deployed") - codecopy(0, dataoffset("C_7_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_7_deployed"), _1) + return(returndatasize(), _1) } } object "C_7_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } @@ -38,17 +41,20 @@ object "D_10" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("D_10_deployed") - codecopy(0, dataoffset("D_10_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("D_10_deployed"), _1) + return(returndatasize(), _1) } } object "D_10_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index 79f6fcae4..630d88885 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -10,17 +10,20 @@ object "C_3" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_3_deployed") - codecopy(0, dataoffset("C_3_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_3_deployed"), _1) + return(returndatasize(), _1) } } object "C_3_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } @@ -38,10 +41,13 @@ object "D_16" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("D_16_deployed") - codecopy(0, dataoffset("D_16_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("D_16_deployed"), _1) + return(returndatasize(), _1) } } object "D_16_deployed" { @@ -50,7 +56,7 @@ object "D_16" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0x26121ff0, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -86,17 +92,20 @@ object "D_16" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_3_deployed") - codecopy(0, dataoffset("C_3_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_3_deployed"), _1) + return(returndatasize(), _1) } } object "C_3_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output index e4ad6b298..06bde1348 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output @@ -10,10 +10,13 @@ object "D_12" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("D_12_deployed") - codecopy(0, dataoffset("D_12_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("D_12_deployed"), _1) + return(returndatasize(), _1) } } object "D_12_deployed" { @@ -22,7 +25,7 @@ object "D_12" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0x26121ff0, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -31,7 +34,7 @@ object "D_12" { return(128, _1) } } - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output index cf559e4bd..ce56ccfa7 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output @@ -10,10 +10,13 @@ object "D_8" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("D_8_deployed") - codecopy(0, dataoffset("D_8_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("D_8_deployed"), _1) + return(returndatasize(), _1) } } object "D_8_deployed" { @@ -22,7 +25,7 @@ object "D_8" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0x26121ff0, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -31,7 +34,7 @@ object "D_8" { return(128, _1) } } - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } diff --git a/test/cmdlineTests/name_simplifier/output b/test/cmdlineTests/name_simplifier/output index ad1cc3cde..90b203ddb 100644 --- a/test/cmdlineTests/name_simplifier/output +++ b/test/cmdlineTests/name_simplifier/output @@ -10,10 +10,13 @@ object "C_59" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_59_deployed") - codecopy(0, dataoffset("C_59_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_59_deployed"), _1) + return(returndatasize(), _1) } } object "C_59_deployed" { @@ -22,7 +25,7 @@ object "C_59" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0xf8eddcc6, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -56,7 +59,7 @@ object "C_59" { return(memPos, sub(abi_encode_uint256_string(memPos, ret, ret_1), memPos)) } } - revert(0, 0) + revert(returndatasize(), returndatasize()) } function abi_encode_uint256_string(headStart, value0, value1) -> tail { @@ -65,14 +68,14 @@ object "C_59" { mstore(add(headStart, _1), 64) let length := mload(value1) mstore(add(headStart, 64), length) - let i := tail + let i := returndatasize() for { } lt(i, length) { i := add(i, _1) } { mstore(add(add(headStart, i), 96), mload(add(add(value1, i), _1))) } if gt(i, length) { - mstore(add(add(headStart, length), 96), tail) + mstore(add(add(headStart, length), 96), returndatasize()) } tail := add(add(headStart, and(add(length, 31), not(31))), 96) } @@ -133,27 +136,27 @@ object "C_59" { } function panic_error_0x32() { - mstore(0, shl(224, 0x4e487b71)) + mstore(returndatasize(), shl(224, 0x4e487b71)) mstore(4, 0x32) - revert(0, 0x24) + revert(returndatasize(), 0x24) } function panic_error_0x41() { - mstore(0, shl(224, 0x4e487b71)) + mstore(returndatasize(), shl(224, 0x4e487b71)) mstore(4, 0x41) - revert(0, 0x24) + revert(returndatasize(), 0x24) } function storage_array_index_access_struct_S_1254() -> slot, offset { - if iszero(lt(slot, 0x02)) { panic_error_0x32() } - slot := add(slot, slot) - offset := offset + if iszero(lt(returndatasize(), 0x02)) { panic_error_0x32() } + slot := add(returndatasize(), returndatasize()) + offset := returndatasize() } function storage_array_index_access_struct_S() -> slot, offset { - if iszero(lt(slot, 0x02)) { panic_error_0x32() } - slot := add(0x02, slot) - offset := offset + if iszero(lt(returndatasize(), 0x02)) { panic_error_0x32() } + slot := add(0x02, returndatasize()) + offset := returndatasize() } } } diff --git a/test/cmdlineTests/object_compiler/output b/test/cmdlineTests/object_compiler/output index 66ad61fb7..793722461 100644 --- a/test/cmdlineTests/object_compiler/output +++ b/test/cmdlineTests/object_compiler/output @@ -5,17 +5,17 @@ Pretty printed source: object "MyContract" { code { { - sstore(0, caller()) + sstore(returndatasize(), caller()) let _1 := datasize("Runtime") - datacopy(0, dataoffset("Runtime"), _1) - return(0, _1) + datacopy(returndatasize(), dataoffset("Runtime"), _1) + return(returndatasize(), _1) } } object "Runtime" { code { { - mstore(0, sload(0)) - return(0, 0x20) + mstore(returndatasize(), sload(returndatasize())) + return(returndatasize(), 0x20) } } } @@ -23,13 +23,13 @@ object "MyContract" { Binary representation: -33600055600b806012600039806000f350fe60005460005260206000f3 +333d55600880600f3d39803df350fe3d543d5260203df3 Text representation: /* "object_compiler/input.yul":128:136 */ caller /* "object_compiler/input.yul":125:126 */ - 0x00 + returndatasize /* "object_compiler/input.yul":118:137 */ sstore dataSize(sub_0) @@ -37,13 +37,13 @@ Text representation: dup1 dataOffset(sub_0) /* "object_compiler/input.yul":125:126 */ - 0x00 + returndatasize /* "object_compiler/input.yul":205:260 */ codecopy /* "object_compiler/input.yul":275:294 */ dup1 /* "object_compiler/input.yul":125:126 */ - 0x00 + returndatasize /* "object_compiler/input.yul":265:295 */ return pop @@ -51,17 +51,17 @@ stop sub_0: assembly { /* "object_compiler/input.yul":397:398 */ - 0x00 + returndatasize /* "object_compiler/input.yul":391:399 */ sload /* "object_compiler/input.yul":397:398 */ - 0x00 + returndatasize /* "object_compiler/input.yul":381:400 */ mstore /* "object_compiler/input.yul":417:421 */ 0x20 /* "object_compiler/input.yul":397:398 */ - 0x00 + returndatasize /* "object_compiler/input.yul":407:422 */ return } diff --git a/test/cmdlineTests/optimizer_array_sload/output b/test/cmdlineTests/optimizer_array_sload/output index a4b9e8a60..6889dfb70 100644 --- a/test/cmdlineTests/optimizer_array_sload/output +++ b/test/cmdlineTests/optimizer_array_sload/output @@ -10,10 +10,13 @@ object "Arraysum_34" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("Arraysum_34_deployed") - codecopy(0, dataoffset("Arraysum_34_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("Arraysum_34_deployed"), _1) + return(returndatasize(), _1) } } object "Arraysum_34_deployed" { @@ -22,7 +25,7 @@ object "Arraysum_34" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0x81d73423, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -44,7 +47,7 @@ object "Arraysum_34" { return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos)) } } - revert(0, 0) + revert(returndatasize(), returndatasize()) } function abi_encode_uint256(headStart, value0) -> tail { @@ -56,9 +59,9 @@ object "Arraysum_34" { memPtr := mload(64) if gt(memPtr, 0xffffffffffffffff) { - mstore(0, shl(224, 0x4e487b71)) + mstore(returndatasize(), shl(224, 0x4e487b71)) mstore(4, 0x41) - revert(0, 0x24) + revert(returndatasize(), 0x24) } mstore(64, memPtr) } @@ -69,9 +72,9 @@ object "Arraysum_34" { } function panic_error_0x11() { - mstore(0, shl(224, 0x4e487b71)) + mstore(returndatasize(), shl(224, 0x4e487b71)) mstore(4, 0x11) - revert(0, 0x24) + revert(returndatasize(), 0x24) } } } diff --git a/test/cmdlineTests/standard_ewasm_requested/output.json b/test/cmdlineTests/standard_ewasm_requested/output.json index 40e7ca65f..aaf46c4a4 100644 --- a/test/cmdlineTests/standard_ewasm_requested/output.json +++ b/test/cmdlineTests/standard_ewasm_requested/output.json @@ -1,13 +1,17 @@ -{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d0100000001330b6000006000017e6000017f60017e0060017e017e60017e017f60027e7e0060017f0060017f017f60027f7f0060037f7f7f0002510408657468657265756d08636f6465436f7079000a08657468657265756d06726576657274000908657468657265756d0c67657443616c6c56616c7565000708657468657265756d0666696e6973680009030d0c0002050208080101040603000503010001060100071102066d656d6f72790200046d61696e00040092030c435f335f6465706c6f7965640061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b0aca040c960102027f057e024010052100200041c0006a210120012000490440000b100a210220012002370000200141086a2002370000200141106a2002370000200141186a100b370000410010024100290000100c2103410041086a290000100c2104410041106a290000100c210520032004842005410041186a290000100c848450450440100f0b428503210642ca012006100d2006100e0b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100841107421022002200041107610087221010b20010b2201027e02404200a71009ad422086210120014200422088a71009ad8421000b20000b2401027e0240428001a71009ad42208621012001428001422088a71009ad8421000b20000b2201027e02402000a71009ad422086210220022000422088a71009ad8421010b20010b3001047f024020011006210220001006210310072104200441c0006a210520052004490440000b20052003200210000b0b2801037f024020001006210110072102200241c0006a210320032002490440000b2003200110030b0b2601037f02401007210010072101200141c0006a210220022001490440000b2002200010010b0b","wast":"(module +{"contracts":{"A":{"C":{"ewasm":{"wasm":"0061736d01000000014e0d6000006000017e6000017f60017e017e60017e017f60047e7e7e7e017f60057e7e7e7e7e0060067e7e7e7e7e7e0060087e7e7e7e7e7e7e7e0060017f0060017f017f60027f7f0060037f7f7f00026e0508657468657265756d08636f6465436f7079000c08657468657265756d06726576657274000b08657468657265756d0c67657443616c6c56616c7565000908657468657265756d0666696e697368000b08657468657265756d1167657452657475726e4461746153697a650002030f0e00020405050a0a0101030701060805030100010610037e0142000b7e0142000b7e0142000b071102066d656d6f72790200046d61696e000500be030c435f335f6465706c6f7965640061736d010000000117056000006000017f60017e017f60017f017f60027f7f0002300208657468657265756d06726576657274000408657468657265756d1167657452657475726e4461746153697a65000103060500020203030503010001060100071102066d656d6f72790200046d61696e00020ab80205ab0103017e027f057e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71006ad422086210320032000422088a71006ad84210420022004370000200241086a2004370000200241106a2004370000428001a71006ad4220862105200241186a2005428001422088a71006ad843700001001ad21061001ad2107200710042006100310000b0b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2001027f0240200010032102200241c0006a210120012002490440000b0b20010b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100541107421022002200041107610057221010b20010b0abd050e820202027f157e024010062100200041c0006a210120012000490440000b100c210220012002370000200141086a2002370000200141106a2002370000200141186a100d370000410010024100290000100e2103410041086a290000100e2104410041106a290000100e210520032004842005410041186a290000100e8484504504400240101021062300210723012108230221090b02401010210a2300210b2301210c2302210d0b200a200b200c200d200620072008200910120b42b103210e02401010210f2300211023012111230221120b200f201020112012429302200e100f0240101021132300211423012115230221160b2013201420152016200e10110b0b2b01017f024042004200420084420084520440000b420042c000422088520440000b42c000a721000b20000b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2901017f024042002000200184200284520440000b42002003422088520440000b2003a721040b20040b2601027f0240200020012002200310082105200541c0006a210420042005490440000b0b20040b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100a411074210220022000411076100a7221010b20010b2201027e02404200a7100bad422086210120014200422088a7100bad8421000b20000b2401027e0240428001a7100bad42208621012001428001422088a7100bad8421000b20000b2201027e02402000a7100bad422086210220022000422088a7100bad8421010b20010b1900024020002001200220031009200410072005100710000b0b1a01047e02401004ad21030b20012400200224012003240220000b15000240200020012002200310092004100710030b0b1b000240200020012002200310092004200520062007100810010b0b","wast":"(module ;; custom section for sub-module - ;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 1c21519afc0397d3ba45d99eb2354c3d74191cd82bffab348d52efabddb63f6a - ;; (@custom \"C_3_deployed\" \"0061736d010000000112046000006000017f60017f017f60027f7f0002130108657468657265756d06726576657274000303060500010102020503010001060100071102066d656d6f72790200046d61696e00010aae02059d0103017e027f037e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71005ad422086210320032000422088a71005ad84210420022004370000200241086a2004370000200241106a2004370000428001a71005ad4220862105200241186a2005428001422088a71005ad843700001003100210000b0b2f02017f017e02404200210120012001200184200184520440000b20012001422088520440000b2001a721000b20000b1e01027f024010022101200141c0006a210020002001490440000b0b20000b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100441107421022002200041107610047221010b20010b\") + ;; The Keccak-256 hash of the text representation of \"C_3_deployed\": 209b9bb495bde13c626083b6782d7b5456ba10f34312f3bfe1ba8017cdf60c12 + ;; (@custom \"C_3_deployed\" \"0061736d010000000117056000006000017f60017e017f60017f017f60027f7f0002300208657468657265756d06726576657274000408657468657265756d1167657452657475726e4461746153697a65000103060500020203030503010001060100071102066d656d6f72790200046d61696e00020ab80205ab0103017e027f057e02404200210020002000200084200084520440000b200042c000422088520440000b42c000a72101200141c0006a210220022001490440000b2000a71006ad422086210320032000422088a71006ad84210420022004370000200241086a2004370000200241106a2004370000428001a71006ad4220862105200241186a2005428001422088a71006ad843700001001ad21061001ad2107200710042006100310000b0b2901017f024042004200420084420084520440000b42002000422088520440000b2000a721010b20010b2001027f0240200010032102200241c0006a210120012002490440000b0b20010b1f01017f024020004108744180fe0371200041087641ff01717221010b20010b1e01027f02402000100541107421022002200041107610057221010b20010b\") (import \"ethereum\" \"codeCopy\" (func $eth.codeCopy (param i32 i32 i32))) (import \"ethereum\" \"revert\" (func $eth.revert (param i32 i32))) (import \"ethereum\" \"getCallValue\" (func $eth.getCallValue (param i32))) (import \"ethereum\" \"finish\" (func $eth.finish (param i32 i32))) + (import \"ethereum\" \"getReturnDataSize\" (func $eth.getReturnDataSize (result i32))) (memory $memory (export \"memory\") 1) (export \"main\" (func $main)) + (global $global_ (mut i64) (i64.const 0)) + (global $global__1 (mut i64) (i64.const 0)) + (global $global__2 (mut i64) (i64.const 0)) (func $main (local $p i32) @@ -17,32 +21,76 @@ (local $z2 i64) (local $z3 i64) (local $_2 i64) + (local $_3 i64) + (local $_4 i64) + (local $_5 i64) + (local $_6 i64) + (local $_7 i64) + (local $_8 i64) + (local $_9 i64) + (local $_10 i64) + (local $_11 i64) + (local $_12 i64) + (local $_13 i64) + (local $_14 i64) + (local $_15 i64) + (local $_16 i64) + (local $_17 i64) + (local $_18 i64) (block $label_ - (local.set $p (call $u256_to_i32_685)) + (local.set $p (call $u256_to_i32_610)) (local.set $r (i32.add (local.get $p) (i32.const 64))) (if (i32.lt_u (local.get $r) (local.get $p)) (then (unreachable))) - (local.set $_1 (call $bswap64_388)) + (local.set $_1 (call $bswap64_366)) (i64.store (local.get $r) (local.get $_1)) (i64.store (i32.add (local.get $r) (i32.const 8)) (local.get $_1)) (i64.store (i32.add (local.get $r) (i32.const 16)) (local.get $_1)) - (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64_389)) + (i64.store (i32.add (local.get $r) (i32.const 24)) (call $bswap64_367)) (call $eth.getCallValue (i32.const 0)) (local.set $z1 (call $bswap64 (i64.load (i32.const 0)))) (local.set $z2 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 8))))) (local.set $z3 (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 16))))) (if (i32.eqz (i64.eqz (i64.or (i64.or (local.get $z1) (local.get $z2)) (i64.or (local.get $z3) (call $bswap64 (i64.load (i32.add (i32.const 0) (i32.const 24)))))))) (then - (call $revert))) - (local.set $_2 (datasize \"C_3_deployed\")) - (call $codecopy (dataoffset \"C_3_deployed\") (local.get $_2)) - (call $return (local.get $_2)) + (block + (local.set $_2 (call $returndatasize_462)) + (local.set $_3 (global.get $global_)) + (local.set $_4 (global.get $global__1)) + (local.set $_5 (global.get $global__2)) + + ) + (block + (local.set $_6 (call $returndatasize_462)) + (local.set $_7 (global.get $global_)) + (local.set $_8 (global.get $global__1)) + (local.set $_9 (global.get $global__2)) + + ) + (call $revert (local.get $_6) (local.get $_7) (local.get $_8) (local.get $_9) (local.get $_2) (local.get $_3) (local.get $_4) (local.get $_5)))) + (local.set $_10 (datasize \"C_3_deployed\")) + (block + (local.set $_11 (call $returndatasize_462)) + (local.set $_12 (global.get $global_)) + (local.set $_13 (global.get $global__1)) + (local.set $_14 (global.get $global__2)) + + ) + (call $codecopy (local.get $_11) (local.get $_12) (local.get $_13) (local.get $_14) (dataoffset \"C_3_deployed\") (local.get $_10)) + (block + (local.set $_15 (call $returndatasize_462)) + (local.set $_16 (global.get $global_)) + (local.set $_17 (global.get $global__1)) + (local.set $_18 (global.get $global__2)) + + ) + (call $return (local.get $_15) (local.get $_16) (local.get $_17) (local.get $_18) (local.get $_10)) ) ) -(func $u256_to_i32_685 +(func $u256_to_i32_610 (result i32) (local $v i32) - (block $label__1 + (block $label__3 (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then (unreachable))) (if (i64.ne (i64.const 0) (i64.shr_u (i64.const 64) (i64.const 32))) (then @@ -53,11 +101,11 @@ (local.get $v) ) -(func $u256_to_i32_687 +(func $u256_to_i32_612 (param $x4 i64) (result i32) (local $v i32) - (block $label__2 + (block $label__4 (if (i64.ne (i64.const 0) (i64.or (i64.or (i64.const 0) (i64.const 0)) (i64.const 0))) (then (unreachable))) (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then @@ -69,26 +117,46 @@ ) (func $u256_to_i32 + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (result i32) (local $v i32) - (local $_1 i64) - (block $label__3 - (local.set $_1 (i64.const 0)) - (if (i64.ne (local.get $_1) (i64.or (i64.or (local.get $_1) (local.get $_1)) (local.get $_1))) (then + (block $label__5 + (if (i64.ne (i64.const 0) (i64.or (i64.or (local.get $x1) (local.get $x2)) (local.get $x3))) (then (unreachable))) - (if (i64.ne (local.get $_1) (i64.shr_u (local.get $_1) (i64.const 32))) (then + (if (i64.ne (i64.const 0) (i64.shr_u (local.get $x4) (i64.const 32))) (then (unreachable))) - (local.set $v (i32.wrap_i64 (local.get $_1))) + (local.set $v (i32.wrap_i64 (local.get $x4))) ) (local.get $v) ) +(func $to_internal_i32ptr + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (result i32) + (local $r i32) + (local $p i32) + (block $label__6 + (local.set $p (call $u256_to_i32 (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4))) + (local.set $r (i32.add (local.get $p) (i32.const 64))) + (if (i32.lt_u (local.get $r) (local.get $p)) (then + (unreachable))) + + ) + (local.get $r) +) + (func $bswap16 (param $x i32) (result i32) (local $y i32) - (block $label__4 + (block $label__7 (local.set $y (i32.or (i32.and (i32.shl (local.get $x) (i32.const 8)) (i32.const 65280)) (i32.and (i32.shr_u (local.get $x) (i32.const 8)) (i32.const 255)))) ) @@ -100,7 +168,7 @@ (result i32) (local $y i32) (local $hi i32) - (block $label__5 + (block $label__8 (local.set $hi (i32.shl (call $bswap16 (local.get $x)) (i32.const 16))) (local.set $y (i32.or (local.get $hi) (call $bswap16 (i32.shr_u (local.get $x) (i32.const 16))))) @@ -108,11 +176,11 @@ (local.get $y) ) -(func $bswap64_388 +(func $bswap64_366 (result i64) (local $y i64) (local $hi i64) - (block $label__6 + (block $label__9 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 0)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 0) (i64.const 32))))))) @@ -120,11 +188,11 @@ (local.get $y) ) -(func $bswap64_389 +(func $bswap64_367 (result i64) (local $y i64) (local $hi i64) - (block $label__7 + (block $label__10 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.const 128)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (i64.const 128) (i64.const 32))))))) @@ -137,7 +205,7 @@ (result i64) (local $y i64) (local $hi i64) - (block $label__8 + (block $label__11 (local.set $hi (i64.shl (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (local.get $x)))) (i64.const 32))) (local.set $y (i64.or (local.get $hi) (i64.extend_i32_u (call $bswap32 (i32.wrap_i64 (i64.shr_u (local.get $x) (i64.const 32))))))) @@ -146,49 +214,55 @@ ) (func $codecopy + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (param $y4 i64) (param $z4 i64) - (local $_1 i32) - (local $_2 i32) - (local $p i32) - (local $r i32) - (block $label__9 - (local.set $_1 (call $u256_to_i32_687 (local.get $z4))) - (local.set $_2 (call $u256_to_i32_687 (local.get $y4))) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.codeCopy (local.get $r) (local.get $_2) (local.get $_1)) + (block $label__12 + (call $eth.codeCopy (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32_612 (local.get $y4)) (call $u256_to_i32_612 (local.get $z4))) ) ) +(func $returndatasize_462 + (result i64) + (local $z1 i64) + (local $z2 i64) + (local $z3 i64) + (local $z4 i64) + (block $label__13 + (local.set $z4 (i64.extend_i32_u (call $eth.getReturnDataSize))) + + ) + (global.set $global_ (local.get $z2)) + (global.set $global__1 (local.get $z3)) + (global.set $global__2 (local.get $z4)) + (local.get $z1) +) + (func $return + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) (param $y4 i64) - (local $_1 i32) - (local $p i32) - (local $r i32) - (block $label__10 - (local.set $_1 (call $u256_to_i32_687 (local.get $y4))) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.finish (local.get $r) (local.get $_1)) + (block $label__14 + (call $eth.finish (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32_612 (local.get $y4))) ) ) (func $revert - (local $_1 i32) - (local $p i32) - (local $r i32) - (block $label__11 - (local.set $_1 (call $u256_to_i32)) - (local.set $p (call $u256_to_i32)) - (local.set $r (i32.add (local.get $p) (i32.const 64))) - (if (i32.lt_u (local.get $r) (local.get $p)) (then - (unreachable))) - (call $eth.revert (local.get $r) (local.get $_1)) + (param $x1 i64) + (param $x2 i64) + (param $x3 i64) + (param $x4 i64) + (param $y1 i64) + (param $y2 i64) + (param $y3 i64) + (param $y4 i64) + (block $label__15 + (call $eth.revert (call $to_internal_i32ptr (local.get $x1) (local.get $x2) (local.get $x3) (local.get $x4)) (call $u256_to_i32 (local.get $y1) (local.get $y2) (local.get $y3) (local.get $y4))) ) ) diff --git a/test/cmdlineTests/standard_yul_optimized/output.json b/test/cmdlineTests/standard_yul_optimized/output.json index 758904e93..9c1f1a89e 100644 --- a/test/cmdlineTests/standard_yul_optimized/output.json +++ b/test/cmdlineTests/standard_yul_optimized/output.json @@ -1,6 +1,6 @@ {"contracts":{"A":{"object":{"evm":{"assembly":" /* \"A\":17:18 */ - 0x00 - 0x00 + returndatasize + returndatasize /* \"A\":11:19 */ mload /* \"A\":20:40 */ @@ -12,6 +12,10 @@ } } ","irOptimized":"object \"object\" { - code { { sstore(mload(0), 0) } } + code { + { + sstore(mload(returndatasize()), returndatasize()) + } + } } "}}},"errors":[{"component":"general","formattedMessage":"Yul is still experimental. Please use the output with care.","message":"Yul is still experimental. Please use the output with care.","severity":"warning","type":"Warning"}]} diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index 3f7c6c294..26076553c 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -1,9 +1,9 @@ ======= viair_subobjects/input.sol:C ======= Binary: -60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd +60806040523415600d573d3dfd5b600880601a3d39803df350fe60806040523d3dfd Binary of the runtime part: -608060405260006000fd +60806040523d3dfd Optimized IR: /******************************************************* * WARNING * @@ -16,17 +16,20 @@ object "C_3" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_3_deployed") - codecopy(0, dataoffset("C_3_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_3_deployed"), _1) + return(returndatasize(), _1) } } object "C_3_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } @@ -35,9 +38,9 @@ object "C_3" { ======= viair_subobjects/input.sol:D ======= Binary: -608060405234156100105760006000fd5b60fb80610020600039806000f350fe6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd +6080604052341561000e573d3dfd5b60f48061001c3d39803df350fe6080604052600436101515610086573d803560e01c6326121ff01415610084573415610029578081fd5b8060031936011215610039578081fd5b6022806080016080811067ffffffffffffffff8211171561005d5761005c6100b8565b5b50806100d260803980608083f01515610078573d82833e3d82fd5b5080610082610090565bf35b505b60006000fd6100d0565b6000604051905067ffffffffffffffff8111156100b0576100af6100b8565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600d573d3dfd5b600880601a3d39803df350fe60806040523d3dfd Binary of the runtime part: -6080604052600436101515610087576000803560e01c6326121ff0141561008557341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100b9565b5b50806100d360803980608083f01515610079573d82833e3d82fd5b5080610083610091565bf35b505b60006000fd6100d1565b6000604051905067ffffffffffffffff8111156100b1576100b06100b9565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd +6080604052600436101515610086573d803560e01c6326121ff01415610084573415610029578081fd5b8060031936011215610039578081fd5b6022806080016080811067ffffffffffffffff8211171561005d5761005c6100b8565b5b50806100d260803980608083f01515610078573d82833e3d82fd5b5080610082610090565bf35b505b60006000fd6100d0565b6000604051905067ffffffffffffffff8111156100b0576100af6100b8565b5b806040525b90565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600d573d3dfd5b600880601a3d39803df350fe60806040523d3dfd Optimized IR: /******************************************************* * WARNING * @@ -50,10 +53,13 @@ object "D_16" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("D_16_deployed") - codecopy(0, dataoffset("D_16_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("D_16_deployed"), _1) + return(returndatasize(), _1) } } object "D_16_deployed" { @@ -62,7 +68,7 @@ object "D_16" { mstore(64, 128) if iszero(lt(calldatasize(), 4)) { - let _1 := 0 + let _1 := returndatasize() if eq(0x26121ff0, shr(224, calldataload(_1))) { if callvalue() { revert(_1, _1) } @@ -98,17 +104,20 @@ object "D_16" { code { { mstore(64, 128) - if callvalue() { revert(0, 0) } + if callvalue() + { + revert(returndatasize(), returndatasize()) + } let _1 := datasize("C_3_deployed") - codecopy(0, dataoffset("C_3_deployed"), _1) - return(0, _1) + codecopy(returndatasize(), dataoffset("C_3_deployed"), _1) + return(returndatasize(), _1) } } object "C_3_deployed" { code { { mstore(64, 128) - revert(0, 0) + revert(returndatasize(), returndatasize()) } } } diff --git a/test/libyul/YulOptimizerTestCommon.cpp b/test/libyul/YulOptimizerTestCommon.cpp index 2f8334eef..db285111c 100644 --- a/test/libyul/YulOptimizerTestCommon.cpp +++ b/test/libyul/YulOptimizerTestCommon.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -362,7 +363,11 @@ YulOptimizerTestCommon::YulOptimizerTestCommon( FakeUnreachableGenerator fakeUnreachableGenerator; fakeUnreachableGenerator(*m_ast); StackLimitEvader::run(*m_context, *m_object, fakeUnreachableGenerator.fakeUnreachables); - }} + }}, + {"zeroByReturndatasizeReplacer", [&]() { + disambiguate(); + ZeroByReturndatasizeReplacer::run(*m_context, *m_ast); + }}, }; } diff --git a/test/libyul/objectCompiler/long_object_name.yul b/test/libyul/objectCompiler/long_object_name.yul index 322079928..4ce89c47d 100644 --- a/test/libyul/objectCompiler/long_object_name.yul +++ b/test/libyul/objectCompiler/long_object_name.yul @@ -13,13 +13,13 @@ object "t" { // /* "source":23:147 */ // dataSize(sub_0) // /* "source":30:31 */ -// 0x00 +// returndatasize // /* "source":23:147 */ // sstore // stop // // sub_0: assembly { // } -// Bytecode: 6000600055fe -// Opcodes: PUSH1 0x0 PUSH1 0x0 SSTORE INVALID +// Bytecode: 60003d55fe +// Opcodes: PUSH1 0x0 RETURNDATASIZE SSTORE INVALID // SourceMappings: 23:124:0:-:0;30:1;23:124 diff --git a/test/libyul/objectCompiler/nested_optimizer.yul b/test/libyul/objectCompiler/nested_optimizer.yul index e4512f03d..7e5b767db 100644 --- a/test/libyul/objectCompiler/nested_optimizer.yul +++ b/test/libyul/objectCompiler/nested_optimizer.yul @@ -19,8 +19,8 @@ object "a" { // ---- // Assembly: // /* "source":48:49 */ -// 0x00 -// 0x00 +// returndatasize +// returndatasize // /* "source":35:50 */ // calldataload // /* "source":107:127 */ @@ -29,13 +29,13 @@ object "a" { // // sub_0: assembly { // /* "source":188:189 */ -// 0x00 -// 0x00 +// returndatasize +// returndatasize // /* "source":175:190 */ // calldataload // /* "source":253:273 */ // sstore // } -// Bytecode: 600060003555fe -// Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE INVALID +// Bytecode: 3d3d3555fe +// Opcodes: RETURNDATASIZE RETURNDATASIZE CALLDATALOAD SSTORE INVALID // SourceMappings: 48:1:0:-:0;;35:15;107:20 diff --git a/test/libyul/objectCompiler/simple_optimizer.yul b/test/libyul/objectCompiler/simple_optimizer.yul index 40234a1db..ea64b3eff 100644 --- a/test/libyul/objectCompiler/simple_optimizer.yul +++ b/test/libyul/objectCompiler/simple_optimizer.yul @@ -9,12 +9,12 @@ // ---- // Assembly: // /* "source":26:27 */ -// 0x00 -// 0x00 +// returndatasize +// returndatasize // /* "source":13:28 */ // calldataload // /* "source":79:99 */ // sstore -// Bytecode: 600060003555 -// Opcodes: PUSH1 0x0 PUSH1 0x0 CALLDATALOAD SSTORE +// Bytecode: 3d3d3555 +// Opcodes: RETURNDATASIZE RETURNDATASIZE CALLDATALOAD SSTORE // SourceMappings: 26:1:0:-:0;;13:15;79:20 diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul index acef62cc5..832db69d7 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi2.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi2.yul @@ -1078,9 +1078,12 @@ // { // { // let _1 := mload(1) -// let _2 := mload(0) -// if slt(sub(_1, _2), 64) { revert(0, 0) } -// sstore(0, and(calldataload(_2), sub(shl(160, 1), 1))) +// let _2 := mload(returndatasize()) +// if slt(sub(_1, _2), 64) +// { +// revert(returndatasize(), returndatasize()) +// } +// sstore(returndatasize(), and(calldataload(_2), sub(shl(160, 1), 1))) // let x0, x1, x2, x3, x4 := abi_decode_addresst_uint256t_bytes_calldatat_enum_Operation(mload(7), mload(8)) // sstore(x1, x0) // sstore(x3, x2) diff --git a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul index 7934c39fd..e694e87ca 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/abi_example1.yul @@ -463,14 +463,14 @@ // // { // { -// let _1 := 0 -// let _2 := mload(_1) +// let _1 := returndatasize() +// let _2 := mload(returndatasize()) // let pos := 0x20 // let length := mload(_2) // mstore(pos, length) // pos := 64 // let srcPtr := add(_2, 0x20) -// let i := _1 +// let i := returndatasize() // for { } lt(i, length) { i := add(i, 1) } // { // let _3 := mload(srcPtr) @@ -489,7 +489,7 @@ // let a, b, c, d := abi_decode_uint256t_uint256t_array_uint256_dynt_array_array_uint256_memory_dyn(mload(0x20), mload(64)) // sstore(a, b) // sstore(c, d) -// sstore(_1, pos) +// sstore(returndatasize(), pos) // } // function abi_decode_array_array_uint256_memory_dyn(offset, end) -> array // { @@ -502,17 +502,26 @@ // let _2 := 0x20 // dst := add(array, _2) // let src := add(offset, _2) -// if gt(add(add(offset, shl(6, length)), _2), end) { revert(0, 0) } -// let i := 0 +// if gt(add(add(offset, shl(6, length)), _2), end) +// { +// revert(returndatasize(), returndatasize()) +// } +// let i := returndatasize() // for { } lt(i, length) { i := add(i, 1) } // { -// if iszero(slt(add(src, _1), end)) { revert(0, 0) } +// if iszero(slt(add(src, _1), end)) +// { +// revert(returndatasize(), returndatasize()) +// } // let dst_1 := allocateMemory_967() // let dst_2 := dst_1 // let src_1 := src // let _3 := add(src, 64) -// if gt(_3, end) { revert(0, 0) } -// let i_1 := 0 +// if gt(_3, end) +// { +// revert(returndatasize(), returndatasize()) +// } +// let i_1 := returndatasize() // for { } lt(i_1, 0x2) { i_1 := add(i_1, 1) } // { // mstore(dst_1, calldataload(src_1)) @@ -551,26 +560,38 @@ // } // value2 := dst_1 // let offset_1 := calldataload(add(headStart, 96)) -// if gt(offset_1, _2) { revert(value3, value3) } +// if gt(offset_1, _2) +// { +// revert(returndatasize(), returndatasize()) +// } // value3 := abi_decode_array_array_uint256_memory_dyn(add(headStart, offset_1), dataEnd) // } // function allocateMemory_967() -> memPtr // { // memPtr := mload(64) // let newFreePtr := add(memPtr, 64) -// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } +// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) +// { +// revert(returndatasize(), returndatasize()) +// } // mstore(64, newFreePtr) // } // function allocateMemory(size) -> memPtr // { // memPtr := mload(64) // let newFreePtr := add(memPtr, size) -// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { revert(0, 0) } +// if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) +// { +// revert(returndatasize(), returndatasize()) +// } // mstore(64, newFreePtr) // } // function array_allocation_size_array_address_dyn_memory(length) -> size // { -// if gt(length, 0xffffffffffffffff) { revert(size, size) } +// if gt(length, 0xffffffffffffffff) +// { +// revert(returndatasize(), returndatasize()) +// } // size := add(shl(5, length), 0x20) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul index dd5facaf0..d70dbf6a6 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function.yul @@ -24,7 +24,7 @@ // // { // { -// sstore(0, A(2, 1)) +// sstore(returndatasize(), A(2, 1)) // sstore(1, A(2, 2)) // sstore(2, A(4, 2)) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul index 005c58778..132d9082f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ackermann_function_if.yul @@ -29,7 +29,7 @@ // // { // { -// sstore(0, A(2, 1)) +// sstore(returndatasize(), A(2, 1)) // sstore(1, A(2, 2)) // sstore(2, A(4, 2)) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/and_or_combination.yul b/test/libyul/yulOptimizerTests/fullSuite/and_or_combination.yul index b5f456054..2d12c32d3 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/and_or_combination.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/and_or_combination.yul @@ -20,6 +20,6 @@ // // { // { -// sstore(sload(0), 0xad9c000000000000823500000000000056ce0000000000002b67) +// sstore(sload(returndatasize()), 0xad9c000000000000823500000000000056ce0000000000002b67) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul index 68640c7ca..4ead8434d 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/aztec.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/aztec.yul @@ -245,8 +245,8 @@ // let challenge := mod(calldataload(0x44), _2) // if gt(m, n) // { -// mstore(0x00, 404) -// revert(0x00, 0x20) +// mstore(returndatasize(), 404) +// revert(returndatasize(), 0x20) // } // let kn := calldataload(add(calldatasize(), not(191))) // mstore(0x2a0, caller()) @@ -255,7 +255,7 @@ // kn := mulmod(sub(_2, kn), challenge, _2) // hashCommitments(notes, n) // let b := add(0x300, shl(7, n)) -// let i := 0 +// let i := returndatasize() // for { } lt(i, n) { i := add(i, 0x01) } // { // let _3 := add(_1, mul(i, 0xc0)) @@ -376,11 +376,11 @@ // } // function hashCommitments(notes, n) // { -// let i := 0 +// let i := returndatasize() // for { } lt(i, n) { i := add(i, 0x01) } // { // calldatacopy(add(0x300, shl(7, i)), add(add(notes, mul(i, 0xc0)), 0x60), 0x80) // } -// mstore(0, keccak256(0x300, shl(7, n))) +// mstore(returndatasize(), keccak256(0x300, shl(7, n))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul index 71ed36d97..6376c4cf4 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/clear_after_if_continue.yul @@ -18,14 +18,17 @@ // { // if y // { -// let _2 := 0 +// let _2 := returndatasize() // revert(_2, _2) // } // } // { // if y { continue } -// sstore(1, 0) +// sstore(1, returndatasize()) +// } +// if y +// { +// revert(returndatasize(), returndatasize()) // } -// if y { revert(0, 0) } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and.yul b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and.yul index 1abea23e7..6b6464985 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and.yul @@ -11,7 +11,7 @@ // // { // { -// let x := calldataload(0) +// let x := calldataload(returndatasize()) // sstore(shr(248, x), and(shr(4, x), 3855)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_2.yul b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_2.yul index 513a23aa5..c20764f79 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_2.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_2.yul @@ -22,14 +22,14 @@ // // { // { -// let x := calldataload(0) +// let x := calldataload(returndatasize()) // let b := and(shl(8, x), 15790080) -// sstore(10, 0) +// sstore(10, returndatasize()) // sstore(11, b) // sstore(12, b) -// sstore(13, 0) +// sstore(13, returndatasize()) // sstore(14, and(shl(251, x), shl(255, 1))) -// sstore(0xf, 0) -// sstore(16, 0) +// sstore(0xf, returndatasize()) +// sstore(16, returndatasize()) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_3.yul b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_3.yul index 17de07de7..a8c81e3a2 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_3.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_3.yul @@ -19,7 +19,7 @@ // // { // { -// let x := calldataload(0) +// let x := calldataload(returndatasize()) // let _1 := shl(8, x) // let _2 := shr(8, x) // sstore(15, x) @@ -27,6 +27,6 @@ // sstore(17, and(_2, sub(shl(248, 1), 16))) // sstore(18, and(_2, sub(shl(244, 1), 1))) // sstore(19, and(_1, sub(shl(252, 1), 256))) -// sstore(20, 0) +// sstore(20, returndatasize()) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_unsplit.yul b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_unsplit.yul index 923a18f4f..57df89c50 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_unsplit.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/combine_shift_and_and_unsplit.yul @@ -13,7 +13,7 @@ // // { // { -// let x := calldataload(0) +// let x := calldataload(returndatasize()) // sstore(shr(248, x), and(shr(4, x), 3855)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul b/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul index 813c2706e..5c2fbdc14 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/create2_and_mask.yul @@ -14,7 +14,7 @@ // { // { // let _1 := sub(shl(160, 1), 1) -// let _2 := 0 +// let _2 := returndatasize() // let a := and(create2(_2, _2, 0x20, _2), _1) // sstore(a, and(_1, create2(_2, _2, 0x20, _2))) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul b/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul index c89c620bb..ad3c66814 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/create_and_mask.yul @@ -14,7 +14,7 @@ // { // { // let _1 := sub(shl(160, 1), 1) -// let a := and(create(0, 0, 0x20), _1) +// let a := and(create(returndatasize(), returndatasize(), 0x20), _1) // sstore(a, and(_1, create(0, 0, 0x20))) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul index 9cdf20193..81114270e 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/devcon_example.yul @@ -21,14 +21,14 @@ // // { // { -// let _1 := calldataload(0) -// let sum := 0 +// let _1 := calldataload(returndatasize()) +// let sum := returndatasize() // let length := calldataload(_1) -// let i := sum +// let i := returndatasize() // for { } lt(i, length) { i := add(i, 1) } // { // sum := add(sum, calldataload(add(add(_1, shl(5, i)), 0x20))) // } -// sstore(0, sum) +// sstore(returndatasize(), sum) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul b/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul index 479bd5f8b..07091801f 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/fibonacci.yul @@ -25,7 +25,7 @@ // // { // { -// sstore(0, fib(0)) +// sstore(returndatasize(), fib(returndatasize())) // sstore(1, fib(2)) // sstore(2, fib(3)) // sstore(3, fib(4)) diff --git a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul index 5bd34186e..f8cef06d7 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/loopInvariantCodeMotion.yul @@ -24,15 +24,15 @@ // // { // { -// let _1 := calldataload(0) -// let sum := 0 +// let _1 := calldataload(returndatasize()) +// let sum := returndatasize() // let length := calldataload(_1) -// let i := sum +// let i := returndatasize() // let _2 := calldataload(7) // for { } lt(i, length) { i := add(i, 1) } // { // sum := add(sum, add(calldataload(add(add(_1, shl(5, i)), 0x20)), _2)) // } -// sstore(0, sum) +// sstore(returndatasize(), sum) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul b/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul index f0ee054b9..5c89e9f92 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/no_move_loop_orig.yul @@ -18,7 +18,7 @@ // { // for { } iszero(_1) { } // { } -// mstore(192, 0) +// mstore(192, returndatasize()) // } // { if iszero(msize()) { break } } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul b/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul index a0ac5c36d..61fe36205 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/remove_redundant_assignments_in_switch.yul @@ -11,7 +11,7 @@ // // { // { -// switch mload(0) +// switch mload(returndatasize()) // case 0 { } // case 1 { } // default { invalid() } diff --git a/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul b/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul index 40bcbd64a..40111c362 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/reserved_identifiers.yul @@ -26,7 +26,7 @@ // } // function datasize_(x) -> linkersymbol_ // { -// if calldataload(linkersymbol_) { linkersymbol_ := datasize_(x) } +// if calldataload(returndatasize()) { linkersymbol_ := datasize_(x) } // sstore(linkersymbol_, calldataload(linkersymbol_)) // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul b/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul index 38fb86d27..d8cbada3a 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ssaReverse.yul @@ -36,7 +36,7 @@ // // { // { -// let a, b := abi_decode_bytes_calldata(mload(0), mload(1)) +// let a, b := abi_decode_bytes_calldata(mload(returndatasize()), mload(1)) // let a_1, b_1 := abi_decode_bytes_calldata(a, b) // let a_2, b_2 := abi_decode_bytes_calldata(a_1, b_1) // let a_3, b_3 := abi_decode_bytes_calldata(a_2, b_2) @@ -47,10 +47,19 @@ // } // function abi_decode_bytes_calldata(offset, end) -> arrayPos, length // { -// if iszero(slt(add(offset, 0x1f), end)) { revert(arrayPos, arrayPos) } +// if iszero(slt(add(offset, 0x1f), end)) +// { +// revert(returndatasize(), returndatasize()) +// } // length := calldataload(offset) -// if gt(length, 0xffffffffffffffff) { revert(arrayPos, arrayPos) } +// if gt(length, 0xffffffffffffffff) +// { +// revert(returndatasize(), returndatasize()) +// } // arrayPos := add(offset, 0x20) -// if gt(add(add(offset, length), 0x20), end) { revert(0, 0) } +// if gt(add(add(offset, length), 0x20), end) +// { +// revert(returndatasize(), returndatasize()) +// } // } // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/ssaReverseComplex.yul b/test/libyul/yulOptimizerTests/fullSuite/ssaReverseComplex.yul index 4421dd3cd..16bc3f0c9 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/ssaReverseComplex.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/ssaReverseComplex.yul @@ -14,7 +14,7 @@ // // { // { -// let a := mload(0) +// let a := mload(returndatasize()) // let b := mload(1) // if mload(2) // { diff --git a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul index b417991c2..2df75ebd3 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/stack_compressor_msize.yul @@ -47,10 +47,10 @@ // pop(keccak256(gcd(10, 15), or(gt(not(gcd(10, 15)), 1), 1))) // mstore(lt(or(gt(1, or(or(gt(or(or(or(gt(or(gt(_3, _6), 1), _5), _4), _2), 1), 1), _1), 1)), 1), 1), 1) // sstore(not(gcd(10, 15)), 1) -// sstore(0, 0) +// sstore(returndatasize(), returndatasize()) // sstore(2, 1) // extcodecopy(1, msize(), 1, 1) -// sstore(0, 0) +// sstore(returndatasize(), returndatasize()) // sstore(3, 1) // } // function gcd(_a, _b) -> out diff --git a/test/libyul/yulOptimizerTests/fullSuite/switch_inline.yul b/test/libyul/yulOptimizerTests/fullSuite/switch_inline.yul index 65c7512d3..8328fbb04 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/switch_inline.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/switch_inline.yul @@ -9,4 +9,6 @@ // ---- // step: fullSuite // -// { { mstore(9, 0) } } +// { +// { mstore(9, returndatasize()) } +// } diff --git a/test/libyul/yulOptimizerTests/fullSuite/switch_inline_match_default.yul b/test/libyul/yulOptimizerTests/fullSuite/switch_inline_match_default.yul index cff8bd755..dd1d890f8 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/switch_inline_match_default.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/switch_inline_match_default.yul @@ -10,4 +10,6 @@ // ---- // step: fullSuite // -// { { mstore(10, 0) } } +// { +// { mstore(10, returndatasize()) } +// } diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul index b7f0b4afb..c541abf00 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner.yul @@ -20,8 +20,8 @@ // { // { // let out1, out2 := foo(sload(32)) -// sstore(0, out1) -// sstore(0, out2) +// sstore(returndatasize(), out1) +// sstore(returndatasize(), out2) // let out1_1, out2_1 := foo(sload(8)) // } // function foo(b) -> out1, out2 diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_loop.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_loop.yul index b531842db..b177939a2 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_loop.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_loop.yul @@ -18,17 +18,17 @@ // { // { // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // } // function f() // { // let b := 10 -// let _1 := 0 -// let a := calldataload(_1) +// let _1 := returndatasize() +// let a := calldataload(returndatasize()) // let _2 := iszero(a) // for { } iszero(b) { b := add(b, not(0)) } // { diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul index 69b4517eb..7e5962059 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul @@ -15,7 +15,7 @@ // { // { // let x, y, z := f() -// sstore(0, x) +// sstore(returndatasize(), x) // sstore(1, y) // sstore(1, z) // } diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul index 14f0137cb..0e88a216c 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_return.yul @@ -22,9 +22,9 @@ // { // { // let out1, out2 := foo(sload(32)) -// sstore(0, out1) -// sstore(0, out2) -// sstore(0, 0) +// sstore(returndatasize(), out1) +// sstore(returndatasize(), out2) +// sstore(returndatasize(), returndatasize()) // let out1_1, out2_1 := foo(sload(8)) // } // function foo(b) -> out1, out2 diff --git a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_simple.yul b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_simple.yul index 531b1a6ce..810fffb1e 100644 --- a/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_simple.yul +++ b/test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_simple.yul @@ -16,16 +16,16 @@ // { // { // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // f() -// sstore(0, 1) +// sstore(returndatasize(), 1) // } // function f() // { -// let a := calldataload(0) -// mstore(a, 0) +// let a := calldataload(returndatasize()) +// mstore(a, returndatasize()) // if iszero(a) { leave } // } // } diff --git a/test/yulPhaser/Chromosome.cpp b/test/yulPhaser/Chromosome.cpp index 55bfd8f24..685643d37 100644 --- a/test/yulPhaser/Chromosome.cpp +++ b/test/yulPhaser/Chromosome.cpp @@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(output_operator_should_create_concise_and_unambiguous_strin BOOST_TEST(chromosome.length() == allSteps.size()); BOOST_TEST(chromosome.optimisationSteps() == allSteps); - BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRrmVatpud"); + BOOST_TEST(toString(chromosome) == "flcCUnDvejsxIOoighFTLMRrmVatpudz"); } BOOST_AUTO_TEST_CASE(optimisationSteps_should_translate_chromosomes_genes_to_optimisation_step_names)