[MooreToCore] VariableOp lowered failed
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Dear @maerhart @fabianschuiki ,
When lowering `SV` to `Hw` Dialect, there is a stack dump.
Driver: circt-verilog %s
```
module top();
typedef struct {
int a;
int b;
} ms_t;
ms_t ms;
initial begin
ms = '{ 0, 1};
ms = '{ default:1, int:1};
ms = '{ int:0, int:1};
end
endmodule
```
It can be converted to `moore` Dialect like this
Driver: circt-verilog --ir-moore %s
```
module {
moore.module @top() {
%0 = moore.constant 1 : i32
%1 = moore.constant 0 : i32
%ms = moore.variable : >
moore.procedure initial {
%2 = moore.struct_create %1, %0 : !moore.i32, !moore.i32 -> ustruct<{a: i32, b: i32}>
moore.blocking_assign %ms, %2 : ustruct<{a: i32, b: i32}>
%3 = moore.struct_create %0, %0 : !moore.i32, !moore.i32 -> ustruct<{a: i32, b: i32}>
moore.blocking_assign %ms, %3 : ustruct<{a: i32, b: i32}>
moore.blocking_assign %ms, %3 : ustruct<{a: i32, b: i32}>
moore.return
}
moore.output
}
}
```
But it got stack dump when casting `hw::InOutType`. Maybe `structType` should be converted somehow.
This is part of error codes.
```
#19 0x00005f9660f42af4 (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:1958:21
#20 0x00005f9660f3b100 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:1850:17
#21 0x00005f9660f3aa73 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:2384:26
#22 0x00005f9660f3b41f mlir::OperationConverter::convertOperations(llvm::ArrayRef) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:2436:16
#23 0x00005f9660f3fdfc mlir::applyFullConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:3447:22
#24 0x00005f9660f3fe9d mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /home/pluto/Documents/circt/circt/llvm/mlir/lib/Transforms/Utils/DialectConversion.cpp:3453:10
#25 0x00005f965faed60d (anonymous namespace)::MooreToCorePass::runOnOperation() /home/pluto/Documents/circt/circt/lib/Conversion/MooreToCore/MooreToCore.cpp:1398:14
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the three struct assignments with circt-verilog and inspect MooreToCore.cpp around MooreToCorePass::runOnOperation at line 1398. Trace the VariableOp lowering and the cast involving hw::InOutType and structType. Done means the example lowers without a stack dump and the resulting conversion remains valid.
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