Skip to content

Commit 5844955

Browse files
committed
evmasm: Support struct array copying from memory/calldata to storage in evmasm pipeline
1 parent 089b04b commit 5844955

7 files changed

+11
-56
lines changed

libsolidity/codegen/ArrayUtils.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
7171
"Copying nested calldata dynamic arrays to storage is not implemented in the old code generator."
7272
);
7373
}
74-
else
75-
{
76-
// TODO: This limitation can now be removed since we use Yul utility functions that handle non-value types correctly.
77-
// The old inline assembly implementation couldn't handle copying arrays of non-value types from memory or calldata to storage,
78-
// but the Yul functions support them. We keep this check temporarily for backward compatibility.
79-
bool fromMemoryOrCalldata = _sourceType.location() == DataLocation::Memory || _sourceType.location() == DataLocation::CallData;
80-
solUnimplementedAssert(
81-
_sourceType.baseType()->isValueType() || !fromMemoryOrCalldata,
82-
"Copying of type " + _sourceType.toString(false) + " to storage is not supported in legacy (only supported by the IR pipeline). " +
83-
"Hint: try compiling with `--via-ir` (CLI) or the equivalent `viaIR: true` (Standard JSON)."
84-
);
85-
}
8674

8775
if (haveSourceLengthOnStack)
8876
{

test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma abicoder v2;
1+
pragma abicoder v2;
22

33
contract C {
44
struct S {
@@ -13,8 +13,8 @@ contract C {
1313
return (s[2].a, s[1].b, s[0].c);
1414
}
1515
}
16-
// ====
17-
// compileViaYul: true
1816
// ----
1917
// f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12
2018
// gas irOptimized: 120751
19+
// gas legacy: 126254
20+
// gas legacyOptimized: 121447

test/libsolidity/semanticTests/array/copying/array_of_struct_memory_to_storage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ contract C {
1515
return (s[2].a, s[1].b, s[0].c);
1616
}
1717
}
18-
// ====
19-
// compileViaYul: true
2018
// ----
2119
// f() -> 10, 11, 12
2220
// gas irOptimized: 118796
21+
// gas legacy: 124947
22+
// gas legacyOptimized: 119164

test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_calldata_to_storage.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma abicoder v2;
1+
pragma abicoder v2;
22

33
contract C {
44
struct S {
@@ -19,8 +19,8 @@ contract C {
1919
return (s[1].a.length, s[1].a[0]);
2020
}
2121
}
22-
// ====
23-
// compileViaYul: true
2422
// ----
2523
// f((uint256[])[]): 0x20, 3, 0x60, 0x60, 0x60, 0x20, 3, 1, 2, 3 -> 3, 1
2624
// gas irOptimized: 327461
25+
// gas legacy: 332254
26+
// gas legacyOptimized: 327667

test/libsolidity/semanticTests/array/copying/array_of_structs_containing_arrays_memory_to_storage.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma abicoder v2;
1+
pragma abicoder v2;
22

33
contract C {
44
struct S {
@@ -22,8 +22,8 @@ contract C {
2222
return (s[1].b.length, s[1].c.length, s[1].b[2], s[1].c[0]);
2323
}
2424
}
25-
// ====
26-
// compileViaYul: true
2725
// ----
2826
// f() -> 3, 3, 3, 1
2927
// gas irOptimized: 181928
28+
// gas legacy: 190874
29+
// gas legacyOptimized: 183072

test/libsolidity/syntaxTests/array/copy_calldata_struct_array_to_storage_legacy.sol

Lines changed: 0 additions & 16 deletions
This file was deleted.

test/libsolidity/syntaxTests/array/copy_memory_struct_array_to_storage_legacy.sol

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)