Skip to content
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

[mlir] convert-scf-to-spirv Pass crashed with segmentation fault #59136

Closed
Colloportus0 opened this issue Nov 22, 2022 · 5 comments
Closed

[mlir] convert-scf-to-spirv Pass crashed with segmentation fault #59136

Colloportus0 opened this issue Nov 22, 2022 · 5 comments
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:spirv

Comments

@Colloportus0
Copy link

MLIR built at commit 6c01b5c

Reproduced with:
mlir-opt --convert-scf-to-spirv temp.mlir

module {
  func.func @func1(%arg0: tensor<2x2xi1>, %arg1: f32) -> f32 {
    %true = arith.constant true
    %c36976552_i32 = arith.constant 36976552 : i32
    %cst_4 = arith.constant 1.59615526E+9 : f32
    %true_5 = arith.constant true
    %c1998615473_i32 = arith.constant 1998615473 : i32
    %alloc_46 = memref.alloc() : memref<3xi32>
    %alloc_107 = memref.alloc() : memref<2xi32>
    %94 = scf.if %true_5 -> (i32) {
      scf.yield %c36976552_i32 : i32
    } else {
      scf.yield %c1998615473_i32 : i32
    }
    %214 = scf.if %true -> (memref<3xi32>) {
      scf.yield %alloc_46 : memref<3xi32>
    } else {
      %264 = arith.shrsi %94, %c36976552_i32 : i32
      scf.yield %alloc_46 : memref<3xi32>
    }
    memref.assume_alignment %alloc_107, 8 : memref<2xi32>
    return %cst_4 : f32
  }
}

trace:

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 --convert-scf-to-spirv temp.mlir
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  mlir-opt                 0x00000001032c76f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 72
1  mlir-opt                 0x00000001032c7c14 PrintStackTraceSignalHandler(void*) + 28
2  mlir-opt                 0x00000001032c5d18 llvm::sys::RunSignalHandlers() + 148
3  mlir-opt                 0x00000001032c94e4 SignalHandler(int) + 252
4  libsystem_platform.dylib 0x000000019fc254c4 _sigtramp + 56
5  mlir-opt                 0x0000000103a6c974 mlir::Type::getDialect() const + 28
6  mlir-opt                 0x0000000103a6c974 mlir::Type::getDialect() const + 28
7  mlir-opt                 0x00000001073813b0 mlir::Type::getContext() const + 24
8  mlir-opt                 0x000000010552bd84 mlir::spirv::PointerType::get(mlir::Type, mlir::spirv::StorageClass) + 32
9  mlir-opt                 0x00000001061a1388 void replaceSCFOutputValue<mlir::scf::IfOp, mlir::spirv::SelectionOp>(mlir::scf::IfOp, mlir::spirv::SelectionOp, mlir::ConversionPatternRewriter&, mlir::ScfToSPIRVContextImpl*, llvm::ArrayRef<mlir::Type>) + 240
10 mlir-opt                 0x00000001061a0b24 (anonymous namespace)::IfOpConversion::matchAndRewrite(mlir::scf::IfOp, mlir::scf::IfOpAdaptor, mlir::ConversionPatternRewriter&) const + 1016
11 mlir-opt                 0x00000001061a06bc mlir::OpConversionPattern<mlir::scf::IfOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const + 176
12 mlir-opt                 0x0000000107000b24 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const + 368
13 mlir-opt                 0x0000000107d211e8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) + 1356
14 mlir-opt                 0x0000000107021a78 (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&) + 328
15 mlir-opt                 0x00000001070211cc (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) + 996
16 mlir-opt                 0x00000001070207bc (anonymous namespace)::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) + 64
17 mlir-opt                 0x0000000107004c58 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) + 568
18 mlir-opt                 0x0000000107004988 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) + 124
19 mlir-opt                 0x0000000107004e7c mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) + 72
20 mlir-opt                 0x00000001061a5ed4 (anonymous namespace)::SCFToSPIRVPass::runOnOperation() + 392
21 mlir-opt                 0x0000000106ec44ac mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 512
22 mlir-opt                 0x0000000106ec4b7c mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 364
23 mlir-opt                 0x0000000106ec6dc0 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) + 108
24 mlir-opt                 0x0000000106ec6b98 mlir::PassManager::run(mlir::Operation*) + 864
25 mlir-opt                 0x0000000106eabf94 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 560
26 mlir-opt                 0x0000000106eabb28 processBuffer(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) + 496
27 mlir-opt                 0x0000000106eab8f0 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 204
28 mlir-opt                 0x0000000106eab804 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) + 80
29 mlir-opt                 0x00000001070b692c llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 96
30 mlir-opt                 0x00000001070b6410 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) + 128
31 mlir-opt                 0x0000000106ea9244 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) + 320
32 mlir-opt                 0x0000000106ea944c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) + 296
33 mlir-opt                 0x0000000106eaa010 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 2912
34 mlir-opt                 0x0000000102ae9278 main + 148
35 dyld                     0x0000000120745088 start + 516
@EugeneZelenko EugeneZelenko added mlir crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Nov 22, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 22, 2022

@llvm/issue-subscribers-mlir

@Colloportus0 Colloportus0 changed the title convert-scf-to-spirv Pass crashed with segmentation fault [mlir] convert-scf-to-spirv Pass crashed with segmentation fault Nov 22, 2022
@Colloportus0
Copy link
Author

temp.mlir can be further reduced to

module {
    %true = arith.constant true 
    %alloc = memref.alloc() : memref<3xi32> 
    %214 = scf.if %true -> (memref<3xi32>) {
      scf.yield %alloc : memref<3xi32>
    } else { 
      scf.yield %alloc : memref<3xi32>
    }
}

Considering the pass is lowering SCF to SPIRV, I suggest tagging this issue with mlir:spirv @EugeneZelenko .

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 27, 2022

@llvm/issue-subscribers-mlir-spirv

@kuhar kuhar assigned antiagainst and kuhar and unassigned antiagainst Jan 3, 2023
@kuhar
Copy link
Member

kuhar commented Jan 9, 2023

Minimized repro:

func.func @unsupported_yield_type(%arg0 : memref<8xi32>, %arg1 : memref<8xi32>, %c : i1) {
  %r = scf.if %c -> (memref<8xi32>) {
    scf.yield %arg0 : memref<8xi32>
  } else {
    scf.yield %arg1 : memref<8xi32>
  }
  return
}

@kuhar
Copy link
Member

kuhar commented Jan 9, 2023

Fix submitted for review: https://reviews.llvm.org/D141292

@kuhar kuhar closed this as completed in 80d5400 Jan 9, 2023
CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:spirv
Projects
None yet
Development

No branches or pull requests

5 participants