Skip to content

Commit

Permalink
[FIRRTL][CheckCombLoops] don't crash on force+rwprobeop, workaround. (l…
Browse files Browse the repository at this point in the history
…lvm#6821)

Unbreak this, at cost of missing loops through force, while
the better fix is being worked out.

cc llvm#6820.
  • Loading branch information
dtzSiFive authored Mar 13, 2024
1 parent 2bf582c commit fea328a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Dialect/FIRRTL/Transforms/CheckCombLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,13 @@ class DiscoverLoops {
if (leader == rwProbeClasses.member_end())
return;
auto iter = rwProbeRefersTo.find(*leader);

// This should be found, but for now may not be due to needing
// RWProbeOp support. May cause missed loops involving force for now.
// https://github.com/llvm/circt/issues/6820
if (iter == rwProbeRefersTo.end())
return;

assert(iter != rwProbeRefersTo.end());
if (iter->second != dstNode)
drivenBy[iter->second].second.push_back(getOrAddNode(srcVal));
Expand Down
20 changes: 20 additions & 0 deletions test/Dialect/FIRRTL/check-comb-cycles.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1086,3 +1086,23 @@ firrtl.circuit "OutsideDialectSource" {
firrtl.strictconnect %b, %a : !firrtl.uint<32>
}
}

// -----

// Check RWProbeOp + force doesn't crash.
// No loop here.
firrtl.circuit "Issue6820" {
firrtl.module private @Foo(in %clock: !firrtl.clock sym @sym, out %clockProbe_bore: !firrtl.rwprobe<clock>) {
%0 = firrtl.ref.rwprobe <@Foo::@sym> : !firrtl.rwprobe<clock>
firrtl.ref.define %clockProbe_bore, %0 : !firrtl.rwprobe<clock>
}
firrtl.module @Issue6820(in %clock: !firrtl.clock, out %clockProbe: !firrtl.rwprobe<clock>) attributes {convention = #firrtl<convention scalarized>} {
%foo_clock, %foo_clockProbe_bore = firrtl.instance foo @Foo(in clock: !firrtl.clock, out clockProbe_bore: !firrtl.rwprobe<clock>)
firrtl.strictconnect %foo_clock, %clock : !firrtl.clock
firrtl.ref.define %clockProbe, %foo_clockProbe_bore : !firrtl.rwprobe<clock>
%c1_ui1 = firrtl.constant 1 : !firrtl.uint<1>
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1>
%0 = firrtl.asClock %c0_ui1 : (!firrtl.uint<1>) -> !firrtl.clock
firrtl.ref.force %clock, %c1_ui1, %clockProbe, %0 : !firrtl.clock, !firrtl.uint<1>, !firrtl.clock
}
}

0 comments on commit fea328a

Please sign in to comment.