Skip to content

[circt-reduce][FIRRTL] Remove Unused Ports breaks with properties? #10504

@seldridge

Description

@seldridge

Consider the following:

module {
  firrtl.circuit "Foo" {
    firrtl.module private @Bar(out %a: !firrtl.list<anyref>) {
    }
    firrtl.module @Foo(out %a: !firrtl.list<anyref>) {
      %Bar_a = firrtl.instance Bar @Bar(out a: !firrtl.list<anyref>)
      firrtl.propassign %a, %Bar_a : !firrtl.list<anyref>
    }
  }
}

This trips an assertions, assumedly related to this having a property port:

# circt-reduce -test /usr/bin/echo -test-arg hello reduced.0.mlir -o /dev/null -include firrtl-remove-unused-ports
Reading input
Testing input with `/usr/bin/echo`
  with argument `hello`
hello /tmp/circt-reduce-9adcf7.mlir
Initial module has size 297
Trying reduction `firrtl-remove-unused-ports`
circt-reduce: /home/schuylere/scratch/repos/github.com/llvm/circt/lib/Dialect/FIRRTL/FIRRTLOps.cpp:2561: void replaceUsesRespectingErasedPorts(mlir::Operation*, mlir::Operation*, const llvm::BitVector&): Assertion `r1.use_empty() && "removed instance port has uses"' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.	Program arguments: circt-reduce -test /usr/bin/echo -test-arg hello reduced.0.mlir -o /dev/null -include firrtl-remove-unused-ports
 #0 0x0000000000725f1b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x725f1b)
 #1 0x0000000000722e1b llvm::sys::RunSignalHandlers() (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x722e1b)
 #2 0x0000000000722f49 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f5ae8eb0990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #4 0x00007f5ae7cb352f raise (/lib64/libc.so.6+0x4e52f)
 #5 0x00007f5ae7c86e65 abort (/lib64/libc.so.6+0x21e65)
 #6 0x00007f5ae7c86d39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
 #7 0x00007f5ae7cabe86 (/lib64/libc.so.6+0x46e86)
 #8 0x0000000000b1cea7 replaceUsesRespectingErasedPorts(mlir::Operation*, mlir::Operation*, llvm::BitVector const&) FIRRTLOps.cpp:0:0
 #9 0x0000000000b8bb7a circt::firrtl::InstanceOp::cloneWithErasedPortsAndReplaceUses(llvm::BitVector const&) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0xb8bb7a)
#10 0x0000000001927e52 (anonymous namespace)::RemoveUnusedPortsPass::removeUnusedModulePorts(circt::firrtl::FModuleOp, circt::igraph::InstanceGraphNode*) RemoveUnusedPorts.cpp:0:0
#11 0x000000000192947e (anonymous namespace)::RemoveUnusedPortsPass::runOnOperation() RemoveUnusedPorts.cpp:0:0
#12 0x0000000001ac6979 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac6979)
#13 0x0000000001ac6c96 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac6c96)
#14 0x0000000001ac89d5 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#15 0x0000000001ac574d mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac574d)
#16 0x0000000001ac6802 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac6802)
#17 0x0000000001ac6c96 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac6c96)
#18 0x0000000001ac73bd mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac73bd)
#19 0x0000000001ac8756 mlir::PassManager::run(mlir::Operation*) (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x1ac8756)
#20 0x00000000006cb5d4 main (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x6cb5d4)
#21 0x00007f5ae7c9f7e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
#22 0x00000000006d00be _start (/scratch/schuylere/repos/github.com/llvm/circt/build-gcc-g++-Release-on/bin/circt-reduce+0x6d00be)
Aborted

Metadata

Metadata

Assignees

No one assigned

    Labels

    FIRRTLInvolving the `firrtl` dialectReducerRelated to `circt-reduce`bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions