Skip to content

[FIRRTL] EliminateWires: preserve sv.attributes when converting WireOp to NodeOp#10519

Open
bheneffe wants to merge 1 commit into
llvm:mainfrom
Aurora7913:fix-eliminate-wires-drop-sv-attributes
Open

[FIRRTL] EliminateWires: preserve sv.attributes when converting WireOp to NodeOp#10519
bheneffe wants to merge 1 commit into
llvm:mainfrom
Aurora7913:fix-eliminate-wires-drop-sv-attributes

Conversation

@bheneffe
Copy link
Copy Markdown

Hi,

I ran into this while trying to use Chisel's addAttribute() to annotate a wire with (* mark_debug = "true" *) for Vivado debug probes. The attribute was set correctly by LowerAnnotations (as sv.attributes on the FIRRTL WireOp), but never appeared in the emitted SystemVerilog.

Root cause: EliminateWires converts single-writer passive WireOps to NodeOps without copying sv.attributes, so they get silently dropped before LowerToHW runs.

Proposed fix: copy sv.attributes from the WireOp to the replacement NodeOp, matching the existing pattern in LowerToHW.cpp for RegOp and RegResetOp.

Assisted-by: vscode/eicp:Claude Opus 4.6

@circt-bot
Copy link
Copy Markdown

circt-bot Bot commented May 21, 2026

Results of circt-tests run for 8916574 compared to results for 5306f6f: no change to test results.

Copy link
Copy Markdown
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

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

LGTM. Only a few nits.

Thanks for fixing this. This would be surprising when it gets dropped!

Comment thread lib/Dialect/FIRRTL/Transforms/EliminateWires.cpp Outdated
Comment thread lib/Dialect/FIRRTL/Transforms/EliminateWires.cpp Outdated
Comment thread test/Dialect/FIRRTL/eliminate-wires.mlir Outdated
Comment thread test/Dialect/FIRRTL/eliminate-wires.mlir Outdated
Comment thread test/Dialect/FIRRTL/eliminate-wires.mlir
…p to NodeOp

When LowerAnnotations processes firrtl.AttributeAnnotation (the mechanism
used by Chisel's addAttribute()), it sets sv.attributes on the FIRRTL
WireOp. EliminateWires then converts single-writer passive WireOps to
NodeOps without copying sv.attributes, causing attributes like mark_debug
to be silently dropped before LowerToHW runs.

Copy sv.attributes from the WireOp to the replacement NodeOp, matching
the existing pattern in LowerToHW.cpp for RegOp and RegResetOp.

Assisted-by: vscode/eicp:Claude Opus 4.6
@bheneffe bheneffe force-pushed the fix-eliminate-wires-drop-sv-attributes branch from 8916574 to 500a664 Compare May 21, 2026 17:42
@bheneffe
Copy link
Copy Markdown
Author

Hey @seldridge
I'm a first time contributor to this repo, so CI isn't kicking in ;
could you please approve the CI workflow run?
Cheers

@circt-bot
Copy link
Copy Markdown

circt-bot Bot commented May 28, 2026

Results of circt-tests run for 500a664 compared to results for 5306f6f:

sv-tests

Changes in emitted diagnostics:

  • -13 total change
  • -7 error: unsupported construct: Checker
  • -2 error: unsupported construct: NetType
  • -2 error: use of undeclared identifier 'clk2'
  • -2 error: use of undeclared identifier 'clock'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants