Fix array copying check.

This commit is contained in:
chriseth
2021-09-29 10:00:14 +02:00
parent 1b540c175d
commit bb4e3e191d
3 changed files with 87 additions and 1 deletions
@@ -0,0 +1,43 @@
pragma abicoder v2;
type Small is uint16;
type Left is bytes2;
struct S { uint8 a; Small b; Left c; uint8 d; }
contract C {
S public s;
Small[] public small;
Left[] public l;
function f(S calldata _s) external {
s = _s;
}
function g(Small[] calldata _small) external returns (Small[] memory) {
small = _small;
return small;
}
function h(Left[] calldata _left) external returns (Left[] memory) {
l = _left;
return l;
}
}
// ====
// compileViaYul: also
// ----
// s() -> 0, 0, 0x00, 0
// f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 ->
// gas irOptimized: 110778
// gas legacy: 112851
// gas legacyOptimized: 110766
// s() -> 1, 0xff, 0x6162000000000000000000000000000000000000000000000000000000000000, 15
// g(uint16[]): 0x20, 3, 1, 2, 3 -> 0x20, 3, 1, 2, 3
// gas irOptimized: 112669
// gas legacy: 113715
// gas legacyOptimized: 112488
// small(uint256): 0 -> 1
// small(uint256): 1 -> 2
// h(bytes2[]): 0x20, 3, "ab", "cd", "ef" -> 0x20, 3, "ab", "cd", "ef"
// gas irOptimized: 112797
// gas legacy: 113414
// gas legacyOptimized: 112572
// l(uint256): 0 -> 0x6162000000000000000000000000000000000000000000000000000000000000
// l(uint256): 1 -> 0x6364000000000000000000000000000000000000000000000000000000000000
@@ -0,0 +1,43 @@
pragma abicoder v2;
type Small is uint16;
type Left is bytes2;
struct S { uint8 a; Small b; Left c; uint8 d; }
contract C {
S public s;
Small[] public small;
Left[] public l;
function f(S memory _s) public {
s = _s;
}
function g(Small[] memory _small) public returns (Small[] memory) {
small = _small;
return small;
}
function h(Left[] memory _left) public returns (Left[] memory) {
l = _left;
return l;
}
}
// ====
// compileViaYul: also
// ----
// s() -> 0, 0, 0x00, 0
// f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 ->
// gas irOptimized: 110788
// gas legacy: 111668
// gas legacyOptimized: 110908
// s() -> 1, 0xff, 0x6162000000000000000000000000000000000000000000000000000000000000, 15
// g(uint16[]): 0x20, 3, 1, 2, 3 -> 0x20, 3, 1, 2, 3
// gas irOptimized: 113144
// gas legacy: 114806
// gas legacyOptimized: 113085
// small(uint256): 0 -> 1
// small(uint256): 1 -> 2
// h(bytes2[]): 0x20, 3, "ab", "cd", "ef" -> 0x20, 3, "ab", "cd", "ef"
// gas irOptimized: 113317
// gas legacy: 114496
// gas legacyOptimized: 113214
// l(uint256): 0 -> 0x6162000000000000000000000000000000000000000000000000000000000000
// l(uint256): 1 -> 0x6364000000000000000000000000000000000000000000000000000000000000