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

[FIRRTL][IMDCE] Add test for dead output ports, NFC #5512

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

youngar
Copy link
Member

@youngar youngar commented Jun 28, 2023

This adds a test to show the behaviour when a dead module instantiates a child module, and uses its output port, that the dead module should not demand the child's port and keep it alive. Technically FIRRTL does not allow dead modules in the circuit, but this pass already supports this.

This adds a test to show the behaviour that when a dead module
instantiates a child module, and uses its output port, that the dead
module should not demand the child's port and keep it alive.
Technically FIRRTL does not allow dead modules in the circuit, but this
pass already supports this.
@youngar youngar added the FIRRTL Involving the `firrtl` dialect label Jun 28, 2023
@youngar youngar requested a review from uenoku June 28, 2023 20:04
@youngar
Copy link
Member Author

youngar commented Jun 28, 2023

This is a follow up from #5480.

@youngar youngar merged commit 43c82bb into llvm:main Jun 28, 2023
5 checks passed
@youngar youngar deleted the firrtl-imdce-moretests branch June 28, 2023 20:42
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

// This module is dead. Since it is the only user of @Blah's output port, the
// output should be deleted.
firrtl.module private @Other(out %out : !firrtl.uint<1>) {
// CHECK: %0 = builtin.unrealized_conversion_cast to !firrtl.uint<1>
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I didn't imagine there was a corner case where unrealized_conversin cast outlives IMDCE pass. Probably we have to just erase modules unreachable from toplevel.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. The FIRRTL Inliner will delete unreachable modules before this pass runs, so this isn't reachable in the firtool pipeline. Arguably the inliner should not be deleting modules at all, but at the time it was trying to maintain the invariant that all modules are reachable from the top level, and so it was supposed to be deleting the modules where every instance was inlined.

Copy link
Member

Choose a reason for hiding this comment

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

at the time it was trying to maintain the invariant that all modules are reachable from the top level, and so it was supposed to be deleting the modules where every instance was inlined.

That's totally reasonable and I think that's good thing to delete such modules in the early pipeline 👍 #5517 should clean up unreachable modules in IMDCE as well.

uenoku added a commit that referenced this pull request Jun 29, 2023
As pointed out in #5512, IMDCE could
leave unrealized conversion casts which are intended only for dummy values
if there was an unreachable module from toplevel.
Even though it won't practically happen, it would be reasonable to perform
such DCE in IMDCE.
uenoku added a commit that referenced this pull request Jun 29, 2023
As pointed out in #5512, if there was an unreachable module from the toplevel, IMDCE could leave unrealized conversion casts which are intended only for dummy values. Even though it won't practically happen, it would be reasonable to perform such DCE in IMDCE.
calebmkim pushed a commit to andrewb1999/circt that referenced this pull request Jul 12, 2023
This adds a test to show the behaviour when a dead module instantiates a
child module, and uses its output port, that the dead module should not
demand the child's port and keep it alive.  Technically FIRRTL does not
allow dead modules in the circuit, but this pass already supports this.
calebmkim pushed a commit to andrewb1999/circt that referenced this pull request Jul 12, 2023
As pointed out in llvm#5512, if there was an unreachable module from the toplevel, IMDCE could leave unrealized conversion casts which are intended only for dummy values. Even though it won't practically happen, it would be reasonable to perform such DCE in IMDCE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants