[FIRRTL][IMDCE] missed optimization to delete dead instance
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
I think that IMDCE is not deleting instances of public modules, which should be allowed. Given the following test case:
```firrtl
FIRRTL version 4.0.0
circuit Foo:
public module Bar:
public module Foo:
inst bar of Bar
```
Which generates the following IR:
```mlir
firrtl.circuit "Foo" {
firrtl.module @Bar() attributes {convention = #firrtl} {
}
firrtl.module @Foo() attributes {convention = #firrtl} {
firrtl.instance bar @Bar()
}
}
```
IMDCE results in the following error message and IR (which is identical to the input):
```
imdcething.fir:3:10: warning: module `Bar` is empty but cannot be removed because the module is public
public module Bar:
^
```
```mlir
// -----// IR Dump After IMDeadCodeElim (firrtl-imdeadcodeelim) //----- //
module {
firrtl.circuit "Foo" {
firrtl.module @Bar() attributes {convention = #firrtl} {
}
firrtl.module @Foo() attributes {convention = #firrtl} {
firrtl.instance bar @Bar()
}
}
}
```
Which overall results in the following verilog:
```verilog
// Generated by CIRCT unknown git version
module Bar();
endmodule
module Foo();
Bar bar ();
endmodule
```
There is no reason for the instance of `bar of Bar` to have stayed alive, and I expect that it should have been deleted.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the FIRRTL IMDCE pass and reproduce the supplied Foo/Bar example, checking why the public Bar instance remains alive. Done means IMDCE removes the unused instance of Bar while preserving the public module and produces Verilog without the instantiation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100