Skip to content

Commit 8677188

Browse files
[mlir] Add tests for Add trailing cleanup for string type in decode
Signed-off-by: Vladimir Radosavljevic <vr@matterlabs.dev>
1 parent ab4557b commit 8677188

File tree

6 files changed

+1386
-1288
lines changed

6 files changed

+1386
-1288
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
contract C {
2+
function tail_after_decode_memory() public returns (uint256) {
3+
bytes memory enc = abi.encode("a");
4+
uint256 tail;
5+
6+
assembly {
7+
// Force decode allocation to reuse this dirty chunk.
8+
let p := mload(0x40)
9+
mstore(add(p, 0x20), not(0))
10+
mstore(add(p, 0x40), not(0))
11+
mstore(0x40, p)
12+
}
13+
14+
string memory s = abi.decode(enc, (string));
15+
16+
assembly {
17+
tail := mload(add(add(s, 0x20), mload(s)))
18+
}
19+
return tail;
20+
}
21+
}
22+
23+
// ====
24+
// compileViaMlir: true
25+
// ----
26+
// tail_after_decode_memory() -> 0

0 commit comments

Comments
 (0)