llvm / llvm/circt

[Moore] Input triggers assertion in canonicalizer infra

Open
#7,531 11 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

`circt-opt -canonicalize` triggers an assertion on the following input. Maybe an upstream bug?

`Assertion failed: (mayBeGraphRegion(*op->getParentRegion()) && "expected that op has no uses"), function operator(), file PatternMatch.cpp, line 182.`

```
module {
moore.module private @snitch_regfile(in %clk_i : !moore.l1, in %raddr_i : !moore.array<2 x l5>, out rdata_o : !moore.array<2 x l32>, in %waddr_i : !moore.array<1 x l5>, in %wdata_i : !moore.array<1 x l32>, in %we_i : !moore.l1) {
%0 = moore.constant 1 : i32
%1 = moore.constant 0 : i32
%rdata_o = moore.variable : >
moore.procedure always_ff {
cf.br ^bb1(%1 : !moore.i32)
^bb1(%3: !moore.i32): // 2 preds: ^bb0, ^bb6
moore.return
^bb2: // no predecessors
cf.br ^bb4
^bb3: // no predecessors
cf.br ^bb4
^bb4: // 2 preds: ^bb2, ^bb3
%4 = moore.add %4, %0 : i32
cf.br ^bb6
^bb5: // no predecessors
cf.br ^bb6
^bb6: // 2 preds: ^bb4, ^bb5
%5 = moore.add %3, %0 : i32
cf.br ^bb1(%5 : !moore.i32)
}
%2 = moore.read %rdata_o : >
moore.output %2 : !moore.array<2 x l32>
}
}
```

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

Run circt-opt -canonicalize on the provided reproducer and inspect the assertion in PatternMatch.cpp at line 182, then trace the canonicalizer operation handling that reaches it. Done means the input no longer triggers the assertion and the failure is covered by a regression 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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.