Skip to content

fix(sv): keep task arguments read before a suspending call - #2089

Merged
mergify[bot] merged 2 commits into
masterfrom
fix/2071-display-host-call-args
Oct 26, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
fix/2071-display-host-call-args

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Closes #2071.

Summary

A system task such as $display evaluated its arguments one by one. A plain argument became a register, and a later argument's call (a plusargs query, file I/O, a distribution) was hoisted after it. When that call is a host request, the process suspends and resumes in a block entered from the kernel dispatch. The earlier register is used after the resume, where its definition does not dominate:

i = 3;
$display("%0d %0d", i, $test$plusargs("verbose"));  // SSA.DEFINITION_DOMINATES_USE

Arguments are still evaluated left to right, which veryl_assert_continue_ff_captures_arguments_before_reporting relies on. Every argument up to the last one that contains a call is now handled in order:

  • A call is hoisted as before.
  • A plain argument is kept in a temporary (keep_argument) at its place in the order. Memory survives the suspension, and the temporary keeps the argument's signedness, real precision and string-handle kind.

Literals and the arguments after the last call are read as before, so a task without calls in its arguments lowers exactly as before.

Tests

  • display_of_plusargs_{interpreter,compiled,native} (sv_plusargs.rs): $display("%0d %0d %0d %0d", i, $test$plusargs("verbose"), $value$plusargs("v=%d", v), v) prints 3 1 1 7. All three fail on master with the issue's error.
  • cargo nextest run -p celox -p celox-frontend-sv with CI's features: 14752 passed. A first version that hoisted all calls before any read broke the argument-order test above, and this version keeps the order.
  • sv-tests conformance with the official runner at the pinned revision (--state-mode both) matches expected.tsv with no changes (1064/1650 two-state, 1075/1650 four-state).

Closes #2071

Change-Id: I74cd699fd95a0ea315260ab27817672e3135690b
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T05:19:41.248588Z 2051911 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear

tignear commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e37230af7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3242 to +3243
*expr = if self.m.calls(expr) {
self.hoist(expr)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture the complete argument after hoisting its calls

When an argument contains a call, hoist only captures the call results; it leaves surrounding variable reads unevaluated. Moving all hoisting before the evaluation loop therefore lets later arguments change the value of an earlier argument. For example, with i = 3, a function f() returning zero, and a function g() setting i = 7, $display("%0d %0d", i + f(), g()) now evaluates the first argument using i == 7, whereas the previous implementation captured it before executing g(). Capture the complete hoisted expression in a temporary at this point, before processing subsequent arguments, to preserve the intended left-to-right argument evaluation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 2051911. Every argument before the last one with a call is now evaluated whole into a temporary at its place: its calls are hoisted first, and then keep_argument evaluates the hoisted expression. That last argument only has its calls run before its own reads, as any expression does. Arguments after it are read as before.

New test ordered_arguments_{interpreter,compiled,native} (sv_plusargs.rs), on your example plus a host request: with i = 3, f() returning 0 and g() setting i = 7 and returning 5, $display("%0d %0d %0d %0d", i + f(), $test$plusargs("verbose"), g(), i) prints 3 1 5 7. Icarus prints the same. Verilator 5.052 prints 7 5 7 for the variant without the host request, because it runs the calls before reading i. The test fails on the previous head with 7 1 5 7.

cargo nextest run -p celox -p celox-frontend-sv with CI's features: 14755 passed. sv-tests conformance (official runner, pinned revision, both modes) is unchanged against expected.tsv.

Hoisting an argument's calls left its other reads for later, so a later argument's call could change them: $display("%0d %0d", i + f(), g()) with g() writing i printed the new i.

Change-Id: I21d256f4b87659330d009ec7cba06314ac2ff1d8
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 45 minutes 14 seconds in the queue, including 43 minutes 36 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify
mergify Bot merged commit 2e63829 into master Oct 26, 2026
23 checks passed
@mergify
mergify Bot deleted the fix/2071-display-host-call-args branch October 26, 2026 06:24
@mergify mergify Bot removed the queued Mergify queue entry label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sv: $display of a variable and $test$plusargs fails SIR verification (SSA.DEFINITION_DOMINATES_USE)

1 participant