InlineAssemblyMemorySideEffectsThe Yul optimizer may incorrectly remove memory writes from inline assembly blocks, that do not access solidity variables.
|The Yul optimizer considers all memory writes in the outermost Yul block that are never read from as unused and removes them. This is valid when that Yul block is the entire Yul program, which is always the case for the Yul code generated by the new via-IR pipeline. Inline assembly blocks are never optimized in isolation when using that pipeline. Instead they are optimized as a part of the whole Yul input. However, the legacy code generation pipeline (which is still the default) runs the Yul optimizer individually on an inline assembly block if the block does not refer to any local variables defined in the surrounding Solidity code. Consequently, memory writes in such inline assembly blocks are removed as well, if the written memory is never read from in the same assembly block, even if the written memory is accessed later, for example by a subsequent inline assembly block.|
- Link: https://blog.soliditylang.org/2022/06/15/inline-assembly-memory-side-effects-bug/
- First Introduced: 0.8.13
- Fixed in Version: 0.8.15
- Severity<: medium