circt icon indicating copy to clipboard operation
circt copied to clipboard

[FIRRTL] Crash with const fields in enum types

Open mbty opened this issue 1 year ago • 2 comments

The following circuit leads to a firtool crash:

circuit c:
  type enum = {|a: const UInt<8>, b: UInt<16>|}
  module c:

The backtrace is the following:

<unknown>:0: error: enum with 'const' elements must be 'const'
firtool: circt/llvm/mlir/include/mlir/IR/StorageUniquerSupport.h:180: static ConcreteT mlir::detail::StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits>::get(mlir::MLIRContext*, Args&& ...) [with Args = {llvm::ArrayRef<circt::firrtl::FEnumType::EnumElement>&, bool&}; ConcreteT = circt::firrtl::FEnumType; BaseT = circt::firrtl::FIRRTLBaseType; StorageT = circt::firrtl::detail::FEnumTypeStorage; UniquerT = mlir::detail::TypeUniquer; Traits = {circt::hw::FieldIDTypeInterface::Trait}]: Assertion `succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.	Program arguments: firtool test.fir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  firtool   0x000060fd2df68080 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 74
1  firtool   0x000060fd2df68493
2  firtool   0x000060fd2df658cb llvm::sys::RunSignalHandlers() + 146
3  firtool   0x000060fd2df67967
4  libc.so.6 0x00007835a396f710
5  libc.so.6 0x00007835a39bf83c
6  libc.so.6 0x00007835a396f668 raise + 24
7  libc.so.6 0x00007835a39574b8 abort + 215
8  libc.so.6 0x00007835a39573dc
9  libc.so.6 0x00007835a3967d26
10 firtool   0x000060fd2edccc62
11 firtool   0x000060fd2edb8cbf circt::firrtl::FEnumType::get(mlir::MLIRContext*, llvm::ArrayRef<circt::firrtl::FEnumType::EnumElement>, bool) + 57
12 firtool   0x000060fd2e0bc1b6
13 firtool   0x000060fd2e0bd6dd
14 firtool   0x000060fd2e0db3c5
15 firtool   0x000060fd2e0db032
16 firtool   0x000060fd2e0dd503
17 firtool   0x000060fd2e0dd9fc circt::firrtl::importFIRFile(llvm::SourceMgr&, mlir::MLIRContext*, mlir::TimingScope&, circt::firrtl::FIRParserOptions) + 807
18 firtool   0x000060fd2de4f516
19 firtool   0x000060fd2de504db
20 firtool   0x000060fd2de506c3
21 firtool   0x000060fd2de50d8f
22 firtool   0x000060fd2de511db main + 486
23 libc.so.6 0x00007835a3958cd0
24 libc.so.6 0x00007835a3958d8a __libc_start_main + 138
25 firtool   0x000060fd2de4ed95 _start + 37

mbty avatar Jan 27 '24 11:01 mbty

Note that changing the definition to

circuit c:
  type enum = const {|a: const UInt<8>, b: UInt<16>|}
  module c:

doesn't seem to improve anything (surprisingly, even the <unknown>:0: error: enum with 'const' elements must be 'const' error remains).

mbty avatar Jan 27 '24 11:01 mbty

Previously: #5884

dtzSiFive avatar Jan 30 '24 21:01 dtzSiFive