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

The IR-based codegen allocated more memory for the struct. #15383

Open
Subway2023 opened this issue Sep 2, 2024 · 0 comments
Open

The IR-based codegen allocated more memory for the struct. #15383

Subway2023 opened this issue Sep 2, 2024 · 0 comments
Labels

Comments

@Subway2023
Copy link

Description

The IR-based codegen allocated more memory for the struct. After optimization, the IR-based codegen should allocate less memory?

Environment

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

Steps to Reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract BugTest {
    struct Complex {
        uint256 x;
        bytes32 y;
        address z;
    }
    function testBug() public  {
        Complex memory a = Complex({
            x: 123456,
            y: keccak256(abi.encodePacked("test")),
            z: address(0x1234567890123456789012345678901234567890)
        });
        bytes memory encoded = abi.encode(a);
        assembly {
            let p := mload(0x40)
            sstore(p, 1)
        }
    }
}

Legacy Codegen

storage:

{'388': '1'}

IR-based Codegen

storage:

{'416': '1'}

The IR-based codegen's free memory pointer is positioned further back.

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