Have the stack optimization in the code transform only reuse slots that are reachable and fix argument slot reuse on functions without return variables.

This commit is contained in:
Daniel Kirchner
2021-06-28 18:11:57 +02:00
committed by hrkrshnn
parent dfce7b667d
commit bc288aacf5
3 changed files with 53 additions and 10 deletions
@@ -0,0 +1,29 @@
{
function f(x, y) {
mstore(0x80, x)
if calldataload(0) { sstore(y, y) }
}
}
// ====
// stackOptimization: true
// ----
// PUSH1 0x17
// JUMP
// JUMPDEST
// DUP1
// PUSH1 0x80
// MSTORE
// POP
// PUSH1 0x0
// CALLDATALOAD
// ISZERO
// PUSH1 0x13
// JUMPI
// DUP1
// DUP2
// SSTORE
// JUMPDEST
// POP
// JUMPDEST
// JUMP
// JUMPDEST