circt
                                
                                 circt copied to clipboard
                                
                                    circt copied to clipboard
                            
                            
                            
                        [FIRRTL] Unused 0-bit firrtl.invalidvalue remains after LowerToHW
Input:
firrtl.circuit "Foo"  {
  firrtl.module @Foo() {
    %invalid_ui0 = firrtl.invalidvalue : !firrtl.uint<0>
  }
}
Output of circt-opt -lower-firrtl-to-hw contains firrtl.invalidvalue for some reason.
  hw.module @Foo() {
    %invalid_ui0 = firrtl.invalidvalue : !firrtl.uint<0>
    hw.output
  }
Two things:
(1) Whatever is causing these to hit LowerToHW should be investigated as an SFC-compliant pass pipeline shouldn't be allowing these to live beyond SFCCompat. (Perhaps there should be an option to warn/error if running SFCCompat?)
(2) LowerToHW should do something with them. I think it used to convert these to zero at some time (which is reasonable to be SFC compatible). It is probably better to lower these to x and make this a hard-error for our internal flow.
(1) Whatever is causing these to hit LowerToHW should be investigated as an SFC-compliant pass pipeline shouldn't be allowing these to live beyond SFCCompat. (Perhaps there should be an option to warn/error if running SFCCompat?)
Yes, I think dead invalid values are not deleted by SFCCompat pass. SFCCompat assumes they are deleted by canonicalizers.
(2) LowerToHW should do something with them. I think it used to convert these to zero at some time (which is reasonable to be SFC compatible). It is probably better to lower these to x and make this a hard-error for our internal flow.
Actually I guess this bug is in the special handling of zero-bit width in LowerToHW because hw.constant 0 : i0 is not allowed now.
For (1), dead invalids are erased by https://github.com/llvm/circt/commit/632e6e1b0e37e95568ccd9607e76ee8e4aaf6b35
Closing this since the original issue is fixed.