feat(mlir): plumb cross-contract dependencies through the MLIR pipeline#461
Draft
hedgar2017 wants to merge 1 commit into
Draft
feat(mlir): plumb cross-contract dependencies through the MLIR pipeline#461hedgar2017 wants to merge 1 commit into
hedgar2017 wants to merge 1 commit into
Conversation
With per-contract MLIR emission, the linker assembles bytecodes across contracts but only sees the dependencies declared on each `EVMContractObject`. The MLIR branch in `solx-core/src/project/contract/mod.rs` was constructing those with only the contract's own runtime identifier, so `new B()` from contract A had no way to resolve B's deploy bytecode at link time. Mirroring how the Yul pipeline walks `datasize`/`dataoffset` calls to populate `Dependencies`, this change adds a `Vec<String>` of cross-contract references to `MlirOutput` and threads it through `solx_mlir::Context` (interior mut, since emitters hold `&Context`), through `solx-core`'s `ContractMLIR`, and into the `Dependencies` struct fed to the assembler. Dormant until an emitter calls `Context::add_dependency` — no test delta today. The follow-up wiring `new B()` to `sol.new` will populate the list and make cross-contract creation linkable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With per-contract MLIR emission, the linker assembles bytecodes across contracts but only sees the dependencies declared on each
EVMContractObject. The MLIR branch insolx-core/src/project/contract/mod.rswas constructing those with only the contract's own runtime identifier, sonew B()from contract A could not resolve B's deploy bytecode at link time — the LLD pass producednon-ref undefined symbol: __datasize__$<hash>$__.The Yul pipeline solves the same problem by walking each Yul object's body for
datasize/dataoffsetliteral-string arguments and pushing them into asolx_codegen_evm::Dependenciesstruct that the assembler later consumes (solx-yul/src/parser/statement/expression/function_call/mod.rs:112-135). This change mirrors that pattern for the MLIR side:MlirOutputcarries aVec<String>of cross-contract references,solx_mlir::Contextaccumulates names viaadd_dependency(interior mut, since emitters hold&Context), andsolx-core'sContractMLIRpropagates them into theDependenciesstruct fed to the assembler.Dormant in this PR — no emitter calls
Context::add_dependencyyet, so the list is always empty and the link behavior is unchanged.tests/solidity/simple -O M3B3produces 1896 passed / 3 failed / 307 invalid both with and without this change. The follow-up PR that lowersnew B()tosol.newwill start populating the list; from that point the assembler will resolve cross-contract deploy-code references the same way it already does for the Yul pipeline.