Skip to content

[mlir] Crash when using --convert-linalg-to-loops #102576

@AnonymousBugreporter1

Description

@AnonymousBugreporter1

I have the following MLIR program:
test.mlir:

module {
  func.func @func1() {
    %true = arith.constant true
    %splat = tensor.splat %true : tensor<12xi1>
    %0 = bufferization.to_memref %splat : memref<12xi1, strided<[?], offset: ?>>
    %1 = bufferization.alloc_tensor() : tensor<12xi1>
    %2 = bufferization.to_memref %1 : memref<12xi1, strided<[?], offset: ?>>
    linalg.transpose ins(%0 : memref<12xi1, strided<[?], offset: ?>>) outs(%2 : memref<12xi1, strided<[?], offset: ?>>) permutation = [0]
    return
  }
}

The above MLIR program will cause a crash when using the following command:

mlir-opt --convert-linalg-to-loops test.mlir

And the crash backtrace is:

mlir-opt: /data/tmp/v0809/llvm-project/llvm/include/llvm/ADT/STLExtras.h:865: llvm::detail::zippy<llvm::detail::zip_first, T, U, Args ...> llvm::zip_equal(T&&, U&&, Args&& ...) [with T = llvm::SmallVectorImpl<mlir::OpFoldResult>&; U = mlir::ResultRange; Args = {}]: Assertion `all_equal({range_size(t), range_size(u), range_size(args)...}) && "Iteratees do not have equal length"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/tmp/v0809/llvm-project/build/bin/mlir-opt --convert-linalg-to-loops test.mlir
 #0 0x00005644c88a32ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x150a2ff)
 #1 0x00005644c88a0374 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fd6490d5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fd648ba200b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fd648b81859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fd648b81729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fd648b92fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x00005644cbbe0500 checkFoldResultTypes(mlir::Operation*, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (.part.0) Operation.cpp:0:0
 #8 0x00005644cbbe298c mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x484998c)
 #9 0x00005644cbbe2d08 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x4849d08)
#10 0x00005644cba795ee (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#11 0x00005644cba7c6bb mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x46e36bb)
#12 0x00005644c9615ebc void (anonymous namespace)::lowerLinalgToLoopsImpl<mlir::scf::ForOp>(mlir::Operation*) Loops.cpp:0:0
#13 0x00005644cb9c3f41 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x462af41)
#14 0x00005644cb9c4319 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x462b319)
#15 0x00005644cb9c5444 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x462c444)
#16 0x00005644cb9b60db performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#17 0x00005644cb9b6aa4 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
#18 0x00005644cb9b6c54 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
#19 0x00005644cbabfade 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) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x4726ade)
#20 0x00005644cb9ae4f9 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x46154f9)
#21 0x00005644cb9b6dc1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x461ddc1)
#22 0x00005644cb9b7286 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x461e286)
#23 0x00005644c87bc6ab main (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x14236ab)
#24 0x00007fd648b83083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#25 0x00005644c88767be _start (/data/tmp/v0809/llvm-project/build/bin/mlir-opt+0x14dd7be)
Aborted (core dumped)

My git version is 6897004.

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:linalg

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions