You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two places where we rematerialize stack slots:
The EVMSingleUseExpression pass handles rematerialization for constants (plus ad-hoc solutions for CALLDATALOAD, ADD).
The StackLayoutGenerator::compressStack also does it for constants, function call labels, symbols, and junk slots.
The suggestion is to handle constants exclusively in the EVMSingleUseExpression pass and remove their handling from other areas. Rematerialization of the remaining rematerializable items (e.g., function call labels, symbols, junk slots) should become the default behavior, rather than relying on the compressStack logic.
The text was updated successfully, but these errors were encountered:
akiramenai
changed the title
Check for logic duplication in stack slots rematerialization logic
[EVM] Check for logic duplication in stack slots rematerialization logic
Oct 25, 2024
Rematerialization of CALLDATALOAD and ADD is not trivial, since we need to rematerialize 2 instructions where second instruction is a constant. In some cases, it is more profitable to reuse results of CALLDATALOAD and ADD from the stack, instead of doing rematerialization.
One of the tests where this is the case is tests/solidity/simple/yul_instructions/keccak256.sol:
There are two places where we rematerialize stack slots:
EVMSingleUseExpression
pass handles rematerialization for constants (plus ad-hoc solutions forCALLDATALOAD
,ADD
).StackLayoutGenerator::compressStack
also does it for constants, function call labels, symbols, and junk slots.The suggestion is to handle constants exclusively in the
EVMSingleUseExpression
pass and remove their handling from other areas. Rematerialization of the remaining rematerializable items (e.g., function call labels, symbols, junk slots) should become the default behavior, rather than relying on thecompressStack
logic.The text was updated successfully, but these errors were encountered: