circt
circt copied to clipboard
[LLHDToLLVM] Signals declared in llhd.proc are never initialized thus leading to simulator crash
In 5592ee2471aa57661ac76336d60b872ed06a70e5 support for llhd.sig inside llhd.proc was added. However, in LLHDToLLVM signals declared inside procs are never initialized. For entities this happens here.
As a result, the simulator crashes when attempting to drive this signal.
An example stack trace:
llhd-sim: /home/merhart/circt/llvm/llvm/include/llvm/ADT/SmallVector.h:273: llvm::SmallVectorTemplateCommon::reference llvm::SmallVectorTemplateCommon<circt::llhd::sim::Signal>::operator[](llvm::SmallVectorTemplateCommon::size_type) [T = circt::llhd::sim::Signal]: Assertion `idx < size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/merhart/circt/build/bin/llhd-sim /home/merhart/circt/test/Dialect/LLHD/Simulator/sim_sig_in_proc.mlir -n 10 -r Foo -shared-libs=/home/merhart/circt/build/lib/libcirct-llhd-signals-runtime-wrappers.so
#0 0x00007f376c0d887a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/merhart/circt/llvm/llvm/lib/Support/Unix/Signals.inc:569:11
#1 0x00007f376c0d8a2b PrintStackTraceSignalHandler(void*) /home/merhart/circt/llvm/llvm/lib/Support/Unix/Signals.inc:636:1
#2 0x00007f376c0d70a6 llvm::sys::RunSignalHandlers() /home/merhart/circt/llvm/llvm/lib/Support/Signals.cpp:103:5
#3 0x00007f376c0d9155 SignalHandler(int) /home/merhart/circt/llvm/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007f376c26e1f0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x141f0)
#5 0x00007f376ba77fbb raise ./signal/../sysdeps/unix/sysv/linux/raise.c:50:1
#6 0x00007f376ba5d864 abort ./stdlib/abort.c:81:7
#7 0x00007f376ba5d749 get_sysdep_segment_value ./intl/loadmsgcat.c:509:8
#8 0x00007f376ba5d749 _nl_load_domain ./intl/loadmsgcat.c:970:34
#9 0x00007f376ba6f3d6 (/lib/x86_64-linux-gnu/libc.so.6+0x383d6)
#10 0x00007f376c08b599 llvm::SmallVectorTemplateCommon<circt::llhd::sim::Signal, void>::operator[](unsigned long) /home/merhart/circt/llvm/llvm/include/llvm/ADT/SmallVector.h:0:5
#11 0x00007f376c08b2ab driveSignal /home/merhart/circt/lib/Dialect/LLHD/Simulator/signals-runtime-wrappers.cpp:64:24
#12 0x00007f376c2840cd
#13 0x00000000006dc046 circt::llhd::sim::Engine::simulate(int, unsigned long) /home/merhart/circt/lib/Dialect/LLHD/Simulator/Engine.cpp:202:5
#14 0x000000000046ca71 main /home/merhart/circt/tools/llhd-sim/llhd-sim.cpp:221:3
#15 0x00007f376ba5f565 __libc_start_main ./csu/../csu/libc-start.c:332:16
#16 0x000000000046c41e _start (/home/merhart/circt/build/bin/llhd-sim+0x46c41e)
FileCheck error: '<stdin>' is empty.
FileCheck command line: /home/merhart/circt/llvm/build/bin/FileCheck /home/merhart/circt/test/Dialect/LLHD/Simulator/sim_sig_in_proc.mlir