llvm / llvm/circt

[circt-verilog] Assertion failure in virtual void mlir::RewriterBase::eraseOp(mlir::Operation*)

Open
#10,877 2 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

# Bug Report: [circt-verilog] Assertion failure in virtual void mlir::RewriterBase::eraseOp(mlir::Operation*)

## Overview
`circt-verilog` encounters a assertion failure when compiling a SystemVerilog module that performs a partial vector assignment inside an `always@*` block.

## Steps to Reproduce
1. Save the following code to a file named `test.sv`:
```verilog
module m(output logic [5:0] out);
always@* begin
out[1] = 0;
end
endmodule

2. Run circt-verilog:
```Bash
circt-verilog test.sv

## Crash Trace / Error Output
```
circt-verilog: /root/circt/llvm/mlir/lib/IR/PatternMatch.cpp:156: virtual void mlir::RewriterBase::eraseOp(mlir::Operation*): Assertion `op->use_empty() && "expected 'op' to have no uses"' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0. Program arguments: ./build_circt/bin/circt-verilog test.sv
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 circt-verilog 0x00005635d9957b11
1 circt-verilog 0x00005635d99544cc
2 circt-verilog 0x00005635d995462e
3 libc.so.6 0x00007fe415811330
4 libc.so.6 0x00007fe41586ab2c pthread_kill + 284
5 libc.so.6 0x00007fe41581127e gsignal + 30
6 libc.so.6 0x00007fe4157f48ff abort + 223
7 libc.so.6 0x00007fe4157f481b
8 libc.so.6 0x00007fe415807517
9 circt-verilog 0x00005635d8cf30d7
10 circt-verilog 0x00005635d8aa79e3
11 circt-verilog 0x00005635d85025df
12 circt-verilog 0x00005635d8508da5
13 circt-verilog 0x00005635d9770413
14 circt-verilog 0x00005635d9771b8f
15 circt-verilog 0x00005635d9750c54
16 circt-verilog 0x00005635d97534d4
17 circt-verilog 0x00005635d96fee63
18 circt-verilog 0x00005635d9862b46
19 circt-verilog 0x00005635d9862e8e
20 circt-verilog 0x00005635d9864cf3
21 circt-verilog 0x00005635d986190d
22 circt-verilog 0x00005635d98629dc
23 circt-verilog 0x00005635d9862e8e
24 circt-verilog 0x00005635d98636e2
25 circt-verilog 0x00005635d9864a5d
26 circt-verilog 0x00005635d84cc915
27 circt-verilog 0x00005635d84866b8
28 libc.so.6 0x00007fe4157f61ca
29 libc.so.6 0x00007fe4157f628b __libc_start_main + 139
30 circt-verilog 0x00005635d84c3475
Aborted (core dumped)
```

## Environment

- **CIRCT branch:** `main`
- **CIRCT commit:** `f85389286e98645845dbc8aaa6c41eebc4836888`
- **LLVM version:** `23.0.0git`
- **LLVM commit:** `b1c56fb53a9c76d6b045ede49083b647ae049ffe`
- **OS:** Linux, Ubuntu 24.04 LTS
- **Architecture:** `x86_64`

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 the provided test.sv reproducer with circt-verilog and inspect the assertion in llvm/mlir/lib/IR/PatternMatch.cpp at RewriterBase::eraseOp. Trace the CIRCT lowering path that handles the partial vector assignment and identify the operation still in use when eraseOp is called. Done means the reproducer no longer aborts and the regression is covered by an appropriate compiler test.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.