Issue 239598
Summary [MLIR] Crash in `arith.addui_extended` lowering with tensor types during `SCF-to-SPIR-V` conversion
Labels mlir
Assignees
Reporter frida-albrecht
    The `--convert-scf-to-spirv` pass crashes with an UNREACHABLE error when lowering `arith.addui_extended` with tensor operands.

test commit: [4fb8315](https://github.com/llvm/llvm-project/commit/4fb83151289b8c9f5255d7e899d11ea94374c394)

test case:
```
module {
  func.func @main(%arg0: tensor<3x6xi32>, %arg1: tensor<3x6xi32>) -> (tensor<3x6xi32>, tensor<3x6xi1>) {
    %sum, %overflow = arith.addui_extended %arg1, %arg1 : tensor<3x6xi32>, tensor<3x6xi1>
 return %sum, %overflow : tensor<3x6xi32>, tensor<3x6xi1>
 }
}

```



Step to reproduce:
```
mlir-opt test.mlir --convert-scf-to-spirv
```

Crash backtrace:
```
unimplemented types for ConstantOp::getOne()
UNREACHABLE executed at /home/llvm-project/llvm-project-latest/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp:773!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: mlir-opt test.mlir --convert-scf-to-spirv
 #0 0x000055e523bf4139 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fdb139)
 #1 0x000055e523bf093c llvm::sys::RunSignalHandlers() (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fd793c)
 #2 0x000055e523bf0aa6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f63c0706520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f63c075a9bc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969bc)
 #5 0x00007f63c0706476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f63c06ec7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000055e523bd48be (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fbb8be)
 #8 0x000055e528f10745 mlir::spirv::ConstantOp::getOne(mlir::Type, mlir::Location, mlir::OpBuilder&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x72f7745)
 #9 0x000055e5286ceb77 (anonymous namespace)::BinaryExtendedOpPattern<mlir::arith::AddUIExtendedOp, mlir::spirv::IAddCarryOp>::matchAndRewrite(mlir::arith::AddUIExtendedOp, mlir::arith::AddUIExtendedOpAdaptor, mlir::ConversionPatternRewriter&) const ArithToSPIRV.cpp:0:0
#10 0x000055e5286c9917 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1<mlir::OpConversionPattern<mlir::arith::AddUIExtendedOp>, mlir::arith::AddUIExtendedOp>(mlir::OpConversionPattern<mlir::arith::AddUIExtendedOp> const&, mlir::arith::AddUIExtendedOp, mlir::arith::AddUIExtendedOp::GenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x6ab0917)
#11 0x000055e5286c9af1 mlir::OpConversionPattern<mlir::arith::AddUIExtendedOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x6ab0af1)
#12 0x000055e52c34778f mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa72e78f)
#13 0x000055e52c39538c mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#14 0x000055e52c396a6a mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa77da6a)
#15 0x000055e52c3414bb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#16 0x000055e52c341974 mlir::OperationConverter::convert(mlir::Operation*, bool) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa728974)
#17 0x000055e52c34be56 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa732e56)
#18 0x000055e52c34d48f applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x000055e52c34d646 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa734646)
#20 0x000055e528519543 (anonymous namespace)::SCFToSPIRVPass::runOnOperation() SCFToSPIRVPass.cpp:0:0
#21 0x000055e52c3fd3b9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7e43b9)
#22 0x000055e52c3fd694 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7e4694)
#23 0x000055e52c3ff2e2 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7e62e2)
#24 0x000055e52c4002b9 mlir::PassManager::run(mlir::Operation*) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xa7e72b9)
#25 0x000055e523cbe696 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x000055e523cbfc4e processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#27 0x000055e523cbfe91 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#28 0x000055e52c7734cd mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0xab5a4cd)
#29 0x000055e523cb9b8a mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#30 0x000055e523cc04d1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20a74d1)
#31 0x000055e523cc0724 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x20a7724)
#32 0x000055e523b95d5c main (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1f7cd5c)
#33 0x00007f63c06edd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x00007f63c06ede40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x000055e523bd39d5 _start (/home/llvm-project/llvm-project-latest/build/bin/mlir-opt+0x1fba9d5)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to