llvm / llvm/llvm-project

[mlir](test-linalg-decompose-ops) mlir-opt crashes at DecomposeLinalgOps.cpp:363 with assertion `!allUsesReplaced && "peeled scalar operation is erased when it wasnt expected to be"' failed.

Open
#220,523 3 comments 0 reactions 0 assignees View on GitHub
crash mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 42f2cd0c980cc1a924619ecaeaa51ca7b55164ab

MLIR Program:
```mlir
#map = affine_map<(d0) -> (d0)>
module {
func.func @m12(%arg0: index, %arg1: index) -> () {
%true = arith.constant true
%c2 = arith.constant 2 : index
%c10 = arith.constant 10 : index
%c11 = arith.constant 11 : index
%c22 = arith.constant 22 : index
%cst_4 = arith.constant dense<26> : vector<10xindex>
%c0 = arith.constant 0 : index
%2 = tensor.empty() : tensor<27xi1>
%alloc_5 = memref.alloc() : memref<27xf32>
%alloc_6 = memref.alloc(%c11, %c10) : memref
%6 = affine.vector_load %alloc_5[%c22] : memref<27xf32>, vector<10xf32>
%10 = tensor.empty() : tensor<27xi1>

%11 = linalg.generic {indexing_maps = [#map, #map, #map, #map], iterator_types = ["parallel"]} ins(%2, %2, %2 : tensor<27xi1>, tensor<27xi1>, tensor<27xi1>) outs(%10 : tensor<27xi1>) {
^bb0(%in: i1, %in_7: i1, %in_8: i1, %out: i1):
bufferization.dealloc_tensor %10 : tensor<27xi1>
%12 = vector.create_mask %c2 : vector<10xi1>
vector.scatter %alloc_6[%c0, %c0, %c10] [%cst_4], %12, %6 : memref, vector<10xindex>, vector<10xi1>, vector<10xf32>
linalg.yield %true : i1
} -> tensor<27xi1>
return
}
}
```

Reproduce Command: `mlir-opt -test-linalg-decompose-ops a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Dialect/Linalg/Transforms/DecomposeLinalgOps.cpp:363: virtual llvm::LogicalResult {anonymous}::DecomposeLinalgOp::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const: Assertion `!allUsesReplaced && "peeled scalar operation is erased when it wasnt expected to be"' failed.
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-linalg-decompose-ops a.mlir
#0 0x00005593cd9a4aff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20adaff)
#1 0x00005593cd9a165c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20aa65c)
#2 0x00005593cd9a1803 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f43c6377420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f43c5e6200b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f43c5e41859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f43c5e41729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f43c5e52fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x00005593d46b0b1e (anonymous namespace)::DecomposeLinalgOp::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const DecomposeLinalgOps.cpp:0:0
#9 0x00005593cdaba7e0 mlir::detail::OpOrInterfaceRewritePatternBase::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x21c37e0)
#10 0x00005593d6e7b5c2 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#11 0x00005593d6e7cb4b mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb585b4b)
#12 0x00005593d6e45c97 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#13 0x00005593d6e49f56 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb552f56)
#14 0x00005593cdab73c7 (anonymous namespace)::TestLinalgDecomposeOps::runOnOperation() TestLinalgDecomposeOps.cpp:0:0
#15 0x00005593d6ee6f81 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5eff81)
#16 0x00005593d6ee7310 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f0310)
#17 0x00005593d6ee93c4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f23c4)
#18 0x00005593d6eea491 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f3491)
#19 0x00005593cda6af7b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x00005593cda6babf processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#21 0x00005593cda6bceb llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#22 0x00005593d72cee55 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb9d7e55)
#23 0x00005593cda61d34 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#24 0x00005593cda6c207 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2175207)
#25 0x00005593cda6c443 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2175443)
#26 0x00005593cd90b9e7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20149e7)
#27 0x00007f43c5e43083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#28 0x00005593cd98148e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208a48e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Start with the reproducer and run `mlir-opt -test-linalg-decompose-ops a.mlir` to confirm the crash. Read `mlir/lib/Dialect/Linalg/Transforms/DecomposeLinalgOps.cpp` around line 363 and the `TestLinalgDecomposeOps.cpp` entry point. Done means the supplied MLIR input no longer triggers the assertion and regression coverage preserves that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.