diff --git a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul new file mode 100644 index 000000000..5046bbb9d --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_with_side_effects.yul @@ -0,0 +1,28 @@ +{ + function fun_revert() -> ret { revert(0, 0) } + function fun_return() -> ret { return(0, 0) } + function empty(a, b) {} + + // Evaluation order in Yul is right to left so fun_revert() should run first. + empty(fun_return(), fun_revert()) +} +// ---- +// step: fullInliner +// +// { +// { +// let ret_7 := 0 +// revert(0, 0) +// let _1 := ret_7 +// let ret_1_10 := 0 +// return(0, 0) +// let a_13 := ret_1_10 +// let b_14 := _1 +// } +// function fun_revert() -> ret +// { revert(0, 0) } +// function fun_return() -> ret_1 +// { return(0, 0) } +// function empty(a, b) +// { } +// } diff --git a/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul new file mode 100644 index 000000000..1e2e86a20 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInliner/call_arguments_without_side_effects.yul @@ -0,0 +1,49 @@ +{ + function empty(a, b, c) {} + + // Constants + empty(111, 222, 333) + + // Variables + let x := 111 + let y := 222 + let z := 333 + empty(x, y, z) + + // Calls + empty(mload(111), sload(222), calldataload(333)) + + // Mix + let a := 222 + empty(111, a, mload(333)) +} +// ---- +// step: fullInliner +// +// { +// { +// let _1 := 333 +// let _2 := 222 +// let a_13 := 111 +// let b_14 := _2 +// let c_15 := _1 +// let x := 111 +// let y := 222 +// let z := 333 +// let a_16 := x +// let b_17 := y +// let c_18 := z +// let _5 := calldataload(333) +// let _7 := sload(222) +// let a_19 := mload(111) +// let b_20 := _7 +// let c_21 := _5 +// let a_1 := 222 +// let _11 := mload(333) +// let a_22 := 111 +// let b_23 := a_1 +// let c_24 := _11 +// } +// function empty(a, b, c) +// { } +// } diff --git a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_with_side_effects.yul b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_with_side_effects.yul new file mode 100644 index 000000000..b5214e8e4 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_with_side_effects.yul @@ -0,0 +1,27 @@ +{ + function fun_revert() -> ret { revert(0, 0) } + function fun_return() -> ret { return(0, 0) } + function empty(a, b) {} + + // Evaluation order in Yul is right to left so fun_revert() should run first. + empty(fun_return(), fun_revert()) +} +// ---- +// step: fullInlinerWithoutSplitter +// +// { +// { +// let ret_1_3 := 0 +// return(0, 0) +// let a_1 := ret_1_3 +// let ret_4 := 0 +// revert(0, 0) +// let b_2 := ret_4 +// } +// function fun_revert() -> ret +// { revert(0, 0) } +// function fun_return() -> ret_1 +// { return(0, 0) } +// function empty(a, b) +// { } +// } diff --git a/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul new file mode 100644 index 000000000..4c0705bd3 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullInlinerWithoutSplitter/call_arguments_without_side_effects.yul @@ -0,0 +1,44 @@ +{ + function empty(a, b, c) {} + + // Constants + empty(111, 222, 333) + + // Variables + let x := 111 + let y := 222 + let z := 333 + empty(x, y, z) + + // Calls + empty(mload(111), sload(222), calldataload(333)) + + // Mix + let a := 222 + empty(111, a, mload(333)) +} +// ---- +// step: fullInlinerWithoutSplitter +// +// { +// { +// let a_2 := 111 +// let b_3 := 222 +// let c_4 := 333 +// let x := 111 +// let y := 222 +// let z := 333 +// let a_5 := x +// let b_6 := y +// let c_7 := z +// let a_8 := mload(111) +// let b_9 := sload(222) +// let c_10 := calldataload(333) +// let a_1 := 222 +// let a_11 := 111 +// let b_12 := a_1 +// let c_13 := mload(333) +// } +// function empty(a, b, c) +// { } +// } diff --git a/test/libyul/yulOptimizerTests/fullSuite/call_arguments_with_side_effects.yul b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_with_side_effects.yul new file mode 100644 index 000000000..c8c969d88 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_with_side_effects.yul @@ -0,0 +1,12 @@ +{ + function fun_revert() -> ret { revert(0, 0) } + function fun_return() -> ret { return(0, 0) } + function empty(a, b) {} + + // Evaluation order in Yul is always right to left so optimized code should reach the revert first. + empty(fun_return(), fun_revert()) +} +// ---- +// step: fullSuite +// +// { { revert(0, 0) } } diff --git a/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul new file mode 100644 index 000000000..fc36bdfa3 --- /dev/null +++ b/test/libyul/yulOptimizerTests/fullSuite/call_arguments_without_side_effects.yul @@ -0,0 +1,48 @@ +{ + function empty(a, b, c) { + mstore(a, 1) + mstore(b, 1) + mstore(c, 1) + } + + // Constants + empty(1, 2, 3) + + // Variables + let x := 4 + let y := 5 + let z := 6 + empty(x, y, z) + + // Calls + empty(mload(7), sload(8), calldataload(9)) + + // Mix + let a := 12 + empty(11, a, mload(13)) + + return(0, 32) +} +// ---- +// step: fullSuite +// +// { +// { +// let _1 := 1 +// mstore(_1, _1) +// mstore(2, _1) +// mstore(3, _1) +// mstore(4, _1) +// mstore(5, _1) +// mstore(6, _1) +// let _2 := sload(8) +// mstore(mload(7), _1) +// mstore(_2, _1) +// mstore(calldataload(9), _1) +// let _3 := mload(13) +// mstore(11, _1) +// mstore(12, _1) +// mstore(_3, _1) +// return(0, 32) +// } +// }