Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Io.interpretOp' handles a non-existent .address opcode and references non-existent properties.id, so the io.self interpretation is incorrect and likely won’t compile.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds interpreter support for the io dialect by extending interpreter state with (1) an entropy source for io.rand and (2) a simple in-flight message queue for io.send/io.recv, and introduces an io address runtime value to represent !io.address at runtime.
Changes:
- Add
RuntimeValue.ioAddrplus refinement support for!io.address. - Extend
MemoryStatewithEntropyStateandNetworkState, and implement entropy/message operations plusIo.interpretOp'(self/send/recv/rand). - Update/extend MLIR tests, including a new interpreter roundtrip test for
io.send/io.recv.
File summaries
| File | Description |
|---|---|
| Veir/RuntimeValue.lean | Adds ioAddr runtime value and string rendering. |
| Veir/Interpreter/Refinement/Basic.lean | Extends runtime refinement relation to cover ioAddr. |
| Veir/Interpreter/Refinement/Lemmas.lean | Adds lemma for extracting ioAddr from refinement evidence. |
| Veir/Interpreter/Basic.lean | Extends interpreter memory state and implements entropy/network + io op interpretation. |
| Test/IO/roundtrip.mlir | Updates IO IR test to use io.self. |
| Test/Interpreter/IO/roundtrip.mlir | Adds interpreter roundtrip test for io.send/io.recv. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4e0598a to
9413f8a
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The IO interpreter currently converts arbitrary-width len operands via truncating toUInt64, which can silently wrap large lengths instead of failing/UB.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
Veir/Interpreter/Basic.lean:1851
lenforio.randis accepted as any integer width, butlen.toNat.toUInt64truncates values aboveUInt64.max. This can wrap the requested byte count instead of failing/UB.
let [.addr addr, .int _ len] := operands.toList | none
let .val len := len | Interp.ub
let len := len.toNat.toUInt64
- Files reviewed: 5/5 changed files
- Comments generated: 3
- Review effort level: Lite
| // RUN: veir-interpret %s | filecheck %s | ||
|
|
||
| // Send `abcd` to our own address, clear the buffer, receive it back, and | ||
| // return the bytes sent, the bytes received, the buffer contents, and the | ||
| // sender. The interpreter assigns itself address 0. |
5aea012 to
270ef40
Compare
13feb45 to
d69004c
Compare
46164c9 to
48ea333
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
48ea333 to
7f0cdd7
Compare
Extends the Interpreter's state by a source of entropy and a network abstraction.
The source of entropy is supposed to be initialized before interpretation starts and allows operations like random number generation to consume random bytes from this source. As soon as no entropy is left, the behavior is UB.
The network abstraction holds the in-flight messages as a FIFO queue and
recvconsumes (& drops) the first message in the queue for the given receiver.