llvm / llvm/circt

[circt-opt][sccp] "Assertion `mightHaveTerminator()' failed." with SCCP

Open
#8,806 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Problem file (reduced with `circt-reduce`:

```mlir
module {
%false = hw.constant false
fsm.machine @mbx_fsm(%arg0: !seq.clock, %arg1: i1, %arg2: i1, %arg3: i1, %arg4: i1, %arg5: i1, %arg6: i1, %arg7: i1, %arg8: i1, %arg9: i1) -> (i1, i1, i1, i1, i1, i1, i1, i1, i1) attributes {initialState = "state_0"} {
fsm.state @state_0 output {
fsm.output %arg2, %false, %false, %false, %false, %false, %false, %false, %false : i1, i1, i1, i1, i1, i1, i1, i1, i1
}
}
}
```

Result:

```bash
ak2518@autobot:/local/scratch/ak2518/RTL-to-FSM-extractor$ circt-opt --sccp weird_2.mlir
circt-opt: /local/scratch/ak2518/RTL-to-FSM-extractor/circt/llvm/mlir/lib/IR/Block.cpp:245: Operation *mlir::Block::getTerminator(): Assertion `mightHaveTerminator()' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0. Program arguments: circt-opt --sccp weird_2.mlir
#0 0x000059b950087338 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x3f54338)
#1 0x000059b950084a65 llvm::sys::RunSignalHandlers() (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x3f51a65)
#2 0x000059b9500880f1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x000079aba3c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000079aba3c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000079aba3c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000079aba3c9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000079aba3c4527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000079aba3c288ff abort ./stdlib/abort.c:81:7
#9 0x000079aba3c2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000079aba3c3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x000059b952ec27ff mlir::Block::getTerminator() (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x6d8f7ff)
#12 0x000059b95406d16d mlir::dataflow::DeadCodeAnalysis::visit(mlir::ProgramPoint*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f3a16d)
#13 0x000059b95406b8a5 mlir::dataflow::DeadCodeAnalysis::initializeRecursively(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f388a5)
#14 0x000059b95406bc8c mlir::dataflow::DeadCodeAnalysis::initializeRecursively(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f38c8c)
#15 0x000059b95406bc8c mlir::dataflow::DeadCodeAnalysis::initializeRecursively(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f38c8c)
#16 0x000059b95406b050 mlir::dataflow::DeadCodeAnalysis::initialize(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f38050)
#17 0x000059b954044f1e mlir::DataFlowSolver::initializeAndRun(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7f11f1e)
#18 0x000059b9535b327b (anonymous namespace)::SCCP::runOnOperation() SCCP.cpp:0:0
#19 0x000059b954021e22 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7eeee22)
#20 0x000059b954022990 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7eef990)
#21 0x000059b95402520c mlir::PassManager::run(mlir::Operation*) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7ef220c)
#22 0x000059b95356ae1b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x000059b95356aa80 llvm::LogicalResult llvm::function_ref>, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#24 0x000059b95359d5d5 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x746a5d5)
#25 0x000059b953563a35 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7430a35)
#26 0x000059b953563ce8 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7430ce8)
#27 0x000059b953563f02 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x7430f02)
#28 0x000059b94ff5b41d main /local/scratch/ak2518/RTL-to-FSM-extractor/circt/tools/circt-opt/circt-opt.cpp:84:0
#29 0x000079aba3c2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#30 0x000079aba3c2a28b call_init ./csu/../csu/libc-start.c:128:20
#31 0x000079aba3c2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#32 0x000059b94ff5af65 _start (/local/scratch/ak2518/RTL-to-FSM-extractor/circt/build/bin/circt-opt+0x3e27f65)
Aborted (core dumped)
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running circt-opt --sccp on the reduced MLIR reproducer and inspect the stack frames through DeadCodeAnalysis and SCCP.cpp. Trace why the FSM state region reaches Block::getTerminator() without a terminator. Done means the reproducer no longer aborts with the mightHaveTerminator assertion, with regression coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.