Issue 131766
Summary [MLIR] `Segmentation fault` when running `tosa-to-linalg` pass
Labels mlir
Assignees
Reporter sweead
    test commit: [bd1be8a](https://github.com/llvm/llvm-project/commit/bd1be8a242384d98ef2087f4571b464e01501f5a)

step to reproduce:
`
mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(tosa-to-linalg))"
` 

test case:
```
 func.func @main(%arg0: tensor<2x3xi32>, %arg1: tensor<2x3xi32>, %arg2: tensor<1xi8>) {
    %0 = tosa.mul %arg0, %arg1, %arg2 : (tensor<2x3xi32>, tensor<2x3xi32>, tensor<1xi8>) -> tensor<2x3xi32>
 return
  }
```

Crash backtrace:
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: mlir-opt test.mlir --pass-pipeline=builtin.module(func.func(tosa-to-linalg))
 #0 0x00005602fd8bb020 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/workdir/llvm-project/build/bin/mlir-opt+0x16ef020)
 #1 0x00005602fd8b7f2f llvm::sys::RunSignalHandlers() (/home/workdir/llvm-project/build/bin/mlir-opt+0x16ebf2f)
 #2 0x00005602fd8b807a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f2b2b187520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000056030094478c mlir::DenseElementsAttr::getNumElements() const (/home/workdir/llvm-project/build/bin/mlir-opt+0x477878c)
 #5 0x000056030064594a auto mlir::DenseElementsAttr::getValues<mlir::IntegerAttr>() const (/home/workdir/llvm-project/build/bin/mlir-opt+0x447994a)
 #6 0x000056030065792d createLinalgBodyCalculationForElementwiseOp(mlir::Operation*, mlir::ValueRange, llvm::ArrayRef<mlir::Type>, mlir::ConversionPatternRewriter&) (.constprop.0) TosaToLinalg.cpp:0:0
 #7 0x000056030065d1af void llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>::callback_fn<emitElementwiseComputation(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Operation*, mlir::ValueRange, llvm::ArrayRef<mlir::OpFoldResult>, mlir::TypeConverter const&)::'lambda0'(mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>(long, mlir::OpBuilder&, mlir::Location, mlir::ValueRange) TosaToLinalg.cpp:0:0
 #8 0x00005602fe1d9daf buildGenericRegion(mlir::OpBuilder&, mlir::Location, mlir::Region&, mlir::ValueRange, mlir::ValueRange, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>) LinalgOps.cpp:0:0
 #9 0x00005602fe23ace2 mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/workdir/llvm-project/build/bin/mlir-opt+0x206ece2)
#10 0x00005602fe23ae8b mlir::linalg::GenericOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypeRange, mlir::ValueRange, mlir::ValueRange, llvm::ArrayRef<mlir::AffineMap>, llvm::ArrayRef<mlir::utils::IteratorType>, llvm::function_ref<void (mlir::OpBuilder&, mlir::Location, mlir::ValueRange)>, llvm::ArrayRef<mlir::NamedAttribute>) (/home/workdir/llvm-project/build/bin/mlir-opt+0x206ee8b)
#11 0x0000560300677620 elementwiseMatchAndRewriteHelper(mlir::Operation*, mlir::ValueRange, mlir::ConversionPatternRewriter&, mlir::TypeConverter const&) TosaToLinalg.cpp:0:0
#12 0x000056030067fa7e mlir::OpConversionPattern<mlir::tosa::MulOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/home/workdir/llvm-project/build/bin/mlir-opt+0x44b3a7e)
#13 0x00005603008877fc mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/workdir/llvm-project/build/bin/mlir-opt+0x46bb7fc)
#14 0x000056030362a926 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/workdir/llvm-project/build/bin/mlir-opt+0x745e926)
#15 0x000056030088ae0c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x000056030088b38c mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/home/workdir/llvm-project/build/bin/mlir-opt+0x46bf38c)
#17 0x000056030088f14c mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/home/workdir/llvm-project/build/bin/mlir-opt+0x46c314c)
#18 0x00005603008917b9 mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/home/workdir/llvm-project/build/bin/mlir-opt+0x46c57b9)
#19 0x0000560300637967 (anonymous namespace)::TosaToLinalg::runOnOperation() TosaToLinalgPass.cpp:0:0
#20 0x00005603007e7201 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461b201)
#21 0x00005603007e76b1 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461b6b1)
#22 0x00005603007e7a56 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#23 0x00005603007e66ed mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461a6ed)
#24 0x00005603007e6fb6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461afb6)
#25 0x00005603007e76b1 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461b6b1)
#26 0x00005603007e8565 mlir::PassManager::run(mlir::Operation*) (/home/workdir/llvm-project/build/bin/mlir-opt+0x461c565)
#27 0x00005603007d82f7 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#28 0x00005603007d8dc5 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#29 0x00005603007d8f7d llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, 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::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#30 0x00005603008e19ae 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::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/home/workdir/llvm-project/build/bin/mlir-opt+0x47159ae)
#31 0x00005603007cfeac mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/workdir/llvm-project/build/bin/mlir-opt+0x4603eac)
#32 0x00005603007d90e0 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/workdir/llvm-project/build/bin/mlir-opt+0x460d0e0)
#33 0x00005603007d9607 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/workdir/llvm-project/build/bin/mlir-opt+0x460d607)
#34 0x00005602fd7fab5f main (/home/workdir/llvm-project/build/bin/mlir-opt+0x162eb5f)
#35 0x00007f2b2b16ed90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007f2b2b16ee40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x00005602fd88e865 _start (/home/workdir/llvm-project/build/bin/mlir-opt+0x16c2865)
Segmentation fault (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to