Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mstore(add(mload(0x80), 0x20), xx) cause IR-based codegen execution revert. #15411

Open
Subway2023 opened this issue Sep 6, 2024 · 0 comments
Labels

Comments

@Subway2023
Copy link

Description

mstore(add(mload(0x80), 0x20), xx) cause IR-based codegen execution revert. However, legacy codegen can execute successfully.

Environment

  • Compiler version: 0.8.27
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): Remix
  • EVM execution environment / backend / blockchain client: None
  • Operating system: None

Steps to Reproduce

contract Test {
    bytes public a;
    uint[] public b;
    function f(uint x) public returns (bytes memory) {
        a = "";
        for (uint i = 0; i < x; ++i) {
            a.push() = bytes1(uint8(i));
        }
        return g(a);
    }
    function g(bytes memory input) public returns (bytes memory) {
        uint[2] memory tempStorage;
        tempStorage[0] = 12345;
        tempStorage[1] = 67890;
        assembly {
            let tempMemory := mload(0x80)
            mstore(add(tempMemory, 0x20), 0x12345678)
        }
    }
}

Lecacy codegen

image

IR-based codegen

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant