Currently, type(C).creationCode.length and type(C).runtimeCode.length cause construction of a bytes array containing the contract bytecode, only to read its length.
This is unnecessary, as we can use yul.datasize. Possible implementations:
- Detect the pattern in the FE and emit
yul.datasize.
- Add MLIR folding:
sol.length(sol.object_code) -> yul.datasize.
Currently,
type(C).creationCode.lengthandtype(C).runtimeCode.lengthcause construction of a bytes array containing the contract bytecode, only to read its length.This is unnecessary, as we can use
yul.datasize. Possible implementations:yul.datasize.sol.length(sol.object_code) -> yul.datasize.