The logic is that it becomes impossible to instantiate the module, so implicitly every instance of the module would have been deleted by specialization, so its safe to remove the module. It might seem a aggressive to delete the module instead of letting something like IMDeadCodeElim remove it, but since we actually remove the layer declarations when they get specialized the enabled layer would become a dangling reference and fails to verify.
If we disable that layer and there are no public modules left, then the circuit just got whacked.
Yeah, had that problem when I was writing the test, there is a comment describing why there is a useless top level module :). I think the way things are going, we are eventually going to remove the concept of the top level module and then having an empty circuit would be fine.
Thanks for taking a look @seldridge.
Right now the code is deleting the module, there is a test here:
https://github.com/llvm/circt/pull/7160/files#diff-aab1abaeffdac59090e622bc6af09a5ca9489665e6cfad4fc7710332d482aec9R220
The logic is that it becomes impossible to instantiate the module, so implicitly every instance of the module would have been deleted by specialization, so its safe to remove the module. It might seem a aggressive to delete the module instead of letting something like IMDeadCodeElim remove it, but since we actually remove the layer declarations when they get specialized the enabled layer would become a dangling reference and fails to verify.
Yeah, had that problem when I was writing the test, there is a comment describing why there is a useless top level module :). I think the way things are going, we are eventually going to remove the concept of the top level module and then having an empty circuit would be fine.