llvm / llvm/circt

[FIRRTL][LowerToHW] An uninstantiated module can crash LowerToHW

Open
#5,562 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I came across the following failure. The problem occurs if a module which is not under the main module in the instance graph includes reference type ports:

```mlir
firrtl.circuit "Foo" {
firrtl.module @Foo() {}
firrtl.module @Bar(in %a: !firrtl.uint<1>, out %b: !firrtl.probe>) {
%0 = firrtl.ref.send %a : !firrtl.uint<1>
firrtl.ref.define %b, %0 : !firrtl.probe>
}
}
```

The failure trips an assert in `LowerToHW` [here](https://github.com/llvm/circt/blob/main/lib/Conversion/FIRRTLToHW/LowerToHW.cpp#L2337):

```
Assertion failed: ((!result || !isa(result.getType())) && "Lowering didn't turn a FIRRTL value into a non-FIRRTL value"), function setLowering, file LowerToHW.cpp, line 2338.
```

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 with the FIRRTL reproducer in the issue and inspect LowerToHW.cpp around line 2337, where setLowering asserts on the uninstantiated module's reference-typed values. Run the reproducer to confirm the crash, then trace how the uninstantiated module and its reference type ports are handled; done means LowerToHW processes this input without triggering the assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.