[SV] Fix regop canonicalizer crashing. (#7564)

This commit is contained in:
Will Dietz 2024-09-03 11:30:03 -05:00 committed by GitHub
parent ac008b1c17
commit 7ba7fc3051
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -303,13 +303,13 @@ LogicalResult RegOp::canonicalize(RegOp op, PatternRewriter &rewriter) {
return failure();
// Check that all operations on the wire are sv.assigns. All other wire
// operations will have been handled by other canonicalization.
for (auto &use : op.getResult().getUses())
if (!isa<AssignOp>(use.getOwner()))
for (auto *user : op.getResult().getUsers())
if (!isa<AssignOp>(user))
return failure();
// Remove all uses of the wire.
for (auto &use : op.getResult().getUses())
rewriter.eraseOp(use.getOwner());
for (auto *user : llvm::make_early_inc_range(op.getResult().getUsers()))
rewriter.eraseOp(user);
// Remove the wire.
rewriter.eraseOp(op);

View File

@ -321,3 +321,11 @@ hw.module @Sampled(in %in: i1) {
%2 = sv.system.sampled %in : i1
hw.output
}
// CHECK-LABEL: @Issue7563
// CHECK-NEXT: hw.output
hw.module @Issue7563(in %in: i8) {
%r = sv.reg : !hw.inout<i8>
sv.assign %r, %in : i8
hw.output
}