Skip to content

[FIRRTL] Crash with fstring type on port #8382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
uenoku opened this issue Apr 2, 2025 · 0 comments
Open

[FIRRTL] Crash with fstring type on port #8382

uenoku opened this issue Apr 2, 2025 · 0 comments

Comments

@uenoku
Copy link
Member

uenoku commented Apr 2, 2025

fstring type would never be on port from the current fir parser but it crashes at LowerToHW:

firrtl.circuit "Printf"{
  // CHECK-LABEL: module Printf
  firrtl.module @Printf(in %clock: !firrtl.fstring) attributes {convention = #firrtl<convention scalarized>} {
  }
}
$  firtool bar.mlir

firtool: /scratch/hidetou/circt/lib/Conversion/FIRRTLToHW/LowerToHW.cpp:2562: llvm::LogicalResult (anonymous namespace)::FIRRTLLowering::setLowering(mlir::Value, mlir::Value): Assertion `(!result || !type_isa<FIRRTLType>(result.getType())) && "Lowering didn't turn a FIRRTL value into a non-FIRRTL value"' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.      Program arguments: ./build/bin/firtool bar.mlir
 #0 0x00000000007ceb97 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /scratch/hidetou/circt/llvm/llvm/lib/Support/Unix/Signals.inc:804:13
 #1 0x00000000007ccad0 llvm::sys::RunSignalHandlers() /scratch/hidetou/circt/llvm/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00000000007cf4aa SignalHandler(int, siginfo_t*, void*) /scratch/hidetou/circt/llvm/llvm/lib/Support/Unix/Signals.inc:0:3
 #3 0x00007f083c2b1cf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
 #4 0x00007f083b36aacf raise (/lib64/libc.so.6+0x4eacf)
 #5 0x00007f083b33dea5 abort (/lib64/libc.so.6+0x21ea5)
 #6 0x00007f083b33dd79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
 #7 0x00007f083b363426 (/lib64/libc.so.6+0x47426)
 #8 0x0000000000d2176a decltype(auto) llvm::dyn_cast<circt::firrtl::LHSType, mlir::Type>(mlir::Type const&) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/Casting.h:650:3
 #9 0x0000000000d2176a decltype(auto) llvm::detail::TypeSwitchBase<llvm::TypeSwitch<mlir::Type, circt::firrtl::FIRRTLBaseType>, mlir::Type>::castValue<circt::firrtl::LHSType, mlir::Type const&>(mlir::Type const&) /scratch/hidetou/circt/llvm/llvm/include/llvm/ADT/TypeSwitch.h:67:12
#10 0x0000000000d2176a llvm::TypeSwitch<mlir::Type, circt::firrtl::FIRRTLBaseType>& llvm::TypeSwitch<mlir::Type, circt::firrtl::FIRRTLBaseType>::Case<circt::firrtl::LHSType, circt::firrtl::getBaseType(mlir::Type)::'lambda0'(auto)>(circt::firrtl::getBaseType(mlir::Type)::'lambda0'(auto)&&) /scratch/hidetou/circt/llvm/llvm/include/llvm/ADT/TypeSwitch.h:101:26
#11 0x0000000000d2176a circt::firrtl::getBaseType(mlir::Type) /scratch/hidetou/circt/include/circt/Dialect/FIRRTL/FIRRTLUtils.h:225:8
#12 0x0000000000d2176a (anonymous namespace)::FIRRTLLowering::setLowering(mlir::Value, mlir::Value) /scratch/hidetou/circt/lib/Conversion/FIRRTLToHW/LowerToHW.cpp:2565:21
#13 0x0000000000d1ee1f llvm::LogicalResult::failed() const /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#14 0x0000000000d1ee1f llvm::failed(llvm::LogicalResult) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#15 0x0000000000d1ee1f (anonymous namespace)::FIRRTLLowering::run() /scratch/hidetou/circt/lib/Conversion/FIRRTLToHW/LowerToHW.cpp:1985:9
#16 0x0000000000d1ee1f (anonymous namespace)::FIRRTLModuleLowering::lowerModuleOperations(circt::hw::HWModuleOp, (anonymous namespace)::CircuitLoweringState&) /scratch/hidetou/circt/lib/Conversion/FIRRTLToHW/LowerToHW.cpp:1977:48
#17 0x0000000000d152a8 llvm::LogicalResult::failed() const /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#18 0x0000000000d152a8 llvm::failed(llvm::LogicalResult) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#19 0x0000000000d152a8 llvm::LogicalResult mlir::failableParallelForEach<llvm::detail::SafeIntIterator<unsigned long, false>, (anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10>(mlir::MLIRContext*, llvm::detail::SafeIntIterator<unsigned long, false>, llvm::detail::SafeIntIterator<unsigned long, false>, (anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10&&) /scratch/hidetou/circt/llvm/llvm/../mlir/include/mlir/IR/Threading.h:46:11
#20 0x0000000000d152a8 llvm::LogicalResult mlir::failableParallelForEach<llvm::iota_range<unsigned long>, (anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10>(mlir::MLIRContext*, llvm::iota_range<unsigned long>&&, (anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10&&) /scratch/hidetou/circt/llvm/llvm/../mlir/include/mlir/IR/Threading.h:92:10
#21 0x0000000000d152a8 llvm::LogicalResult mlir::failableParallelForEachN<(anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10>(mlir::MLIRContext*, unsigned long, unsigned long, (anonymous namespace)::FIRRTLModuleLowering::runOnOperation()::$_10&&) /scratch/hidetou/circt/llvm/llvm/../mlir/include/mlir/IR/Threading.h:107:10
#22 0x0000000000d152a8 (anonymous namespace)::FIRRTLModuleLowering::runOnOperation() /scratch/hidetou/circt/lib/Conversion/FIRRTLToHW/LowerToHW.cpp:753:17
#23 0x000000000148cff9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7::operator()() const /scratch/hidetou/circt/llvm/mlir/lib/Pass/Pass.cpp:0:17
#24 0x000000000148cff9 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) /scratch/hidetou/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#25 0x000000000148cff9 llvm::function_ref<void ()>::operator()() const /scratch/hidetou/circt/llvm/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#26 0x000000000148cff9 void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /scratch/hidetou/circt/llvm/mlir/include/mlir/IR/MLIRContext.h:288:7
#27 0x000000000148cff9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /scratch/hidetou/circt/llvm/mlir/lib/Pass/Pass.cpp:520:21
#28 0x000000000148fdbf llvm::LogicalResult::failed() const /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#29 0x000000000148fdbf llvm::failed(llvm::LogicalResult) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#30 0x000000000148fdbf mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /scratch/hidetou/circt/llvm/mlir/lib/Pass/Pass.cpp:592:9
#31 0x000000000148fdbf mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /scratch/hidetou/circt/llvm/mlir/lib/Pass/Pass.cpp:905:10
#32 0x000000000148fdbf mlir::PassManager::run(mlir::Operation*) /scratch/hidetou/circt/llvm/mlir/lib/Pass/Pass.cpp:885:60
#33 0x0000000000758686 llvm::LogicalResult::failed() const /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#34 0x0000000000758686 llvm::failed(llvm::LogicalResult) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#35 0x0000000000758686 processBuffer(mlir::MLIRContext&, circt::firtool::FirtoolOptions&, mlir::TimingScope&, llvm::SourceMgr&, std::optional<std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>>&) /scratch/hidetou/circt/tools/firtool/firtool.cpp:561:7
#36 0x00000000007572fb processInputSplit(mlir::MLIRContext&, circt::firtool::FirtoolOptions&, mlir::TimingScope&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, std::optional<std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>>&) /scratch/hidetou/circt/tools/firtool/firtool.cpp:619:12
#37 0x0000000000752e60 processInput(mlir::MLIRContext&, circt::firtool::FirtoolOptions&, mlir::TimingScope&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, std::optional<std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>>&) /scratch/hidetou/circt/tools/firtool/firtool.cpp:635:12
#38 0x0000000000752e60 executeFirtool(mlir::MLIRContext&, circt::firtool::FirtoolOptions&) /scratch/hidetou/circt/tools/firtool/firtool.cpp:727:14
#39 0x0000000000751288 llvm::LogicalResult::failed() const /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:43:43
#40 0x0000000000751288 llvm::failed(llvm::LogicalResult) /scratch/hidetou/circt/llvm/llvm/include/llvm/Support/LogicalResult.h:71:58
#41 0x0000000000751288 main /scratch/hidetou/circt/tools/firtool/firtool.cpp:822:8
#42 0x00007f083b356d85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#43 0x000000000075030e _start (./build/bin/firtool+0x75030e)
Aborted

Ideally IR verifier should catch this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant