llvm / llvm/llvm-project

[mlir](test-vector-unrolling-patterns) mlir-opt crashes at SmallVector.h:300 with assertion `idx < size()' failed.

Open
#217,175 1 comment 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: 40cddd81aa9d508beb3b9cfa7fb37a168bfea593

MLIR Program:
```mlir
module {
func.func private @m(%arg0: index, %arg1: vector<8x8x16xi4>, %arg2: vector<16xi1>, %arg3: memref<512xi8>, %arg4: vector<8xi8>) -> vector<8x8x16xi4> {
%c8 = arith.constant 8 : index
%cst_0 = arith.constant dense<0> : vector<16xi4>
%17 = vector.create_mask %c8, %arg0, %c8 : vector<8x8x8xi1>
%19 = vector.extract %17[0, 0] : vector<8xi1> from vector<8x8x8xi1>
%20 = vector.bitcast %cst_0 : vector<16xi4> to vector<8xi8>
%c0 = arith.constant 0 : index
%21 = vector.maskedload %arg3[%c0], %19, %arg4 : memref<512xi8>, vector<8xi1>, vector<8xi8> into vector<8xi8>
%22 = vector.bitcast %21 : vector<8xi8> to vector<16xi4>
%23 = arith.select %arg2, %22, %cst_0 : vector<16xi1>, vector<16xi4>
%24 = vector.insert %23, %arg1 [0, 0] : vector<16xi4> into vector<8x8x16xi4>
return %24 : vector<8x8x16xi4>
}
}
```

Reproduce Command: `mlir-opt -test-vector-unrolling-patterns a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/llvm/include/llvm/ADT/SmallVector.h:300: T& llvm::SmallVectorTemplateCommon >::operator[](llvm::SmallVectorTemplateCommon >::size_type) [with T = long int; = void; llvm::SmallVectorTemplateCommon >::reference = long int&; llvm::SmallVectorTemplateCommon >::size_type = long unsigned int]: Assertion `idx < size()' 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-vector-unrolling-patterns a.mlir
#0 0x00005638a702f7bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20367bf)
#1 0x00005638a702bf5c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2032f5c)
#2 0x00005638a702c103 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f8461525420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f846101000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f8460fef859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f8460fef729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f8461000fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x00005638ae28e022 (anonymous namespace)::UnrollCreateMaskPattern::matchAndRewrite(mlir::vector::CreateMaskOp, mlir::PatternRewriter&) const VectorUnroll.cpp:0:0
#9 0x00005638ae1d7330 mlir::detail::OpOrInterfaceRewritePatternBase::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x91de330)
#10 0x00005638b0200142 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#11 0x00005638b02016a8 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+0xb2086a8)
#12 0x00005638b01cb237 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#13 0x00005638b01cf4f6 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1d64f6)
#14 0x00005638a7967c22 mlir::applyPatternsGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (.constprop.0) TestVectorTransforms.cpp:0:0
#15 0x00005638a7974a01 (anonymous namespace)::TestVectorUnrollingPatterns::runOnOperation() TestVectorTransforms.cpp:0:0
#16 0x00005638b026bce1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb272ce1)
#17 0x00005638b026c070 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+0xb273070)
#18 0x00005638b026c94e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda12'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#19 0x00005638b026acdd mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb271cdd)
#20 0x00005638b026bbbb mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb272bbb)
#21 0x00005638b026c070 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+0xb273070)
#22 0x00005638b026e124 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb275124)
#23 0x00005638b026f1a1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2761a1)
#24 0x00005638a70f5d2b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x00005638a70f686f processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#26 0x00005638a70f6a9b 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
#27 0x00005638b063f725 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+0xb646725)
#28 0x00005638a70ecae4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#29 0x00005638a70f6fb7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20fdfb7)
#30 0x00005638a70f71f3 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20fe1f3)
#31 0x00005638a6f73cf7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f7acf7)
#32 0x00007f8460ff1083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x00005638a700bd8e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2012d8e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with mlir-opt -test-vector-unrolling-patterns a.mlir, then inspect UnrollCreateMaskPattern::matchAndRewrite in VectorUnroll.cpp and the pass in TestVectorTransforms.cpp. Add a regression test using the supplied MLIR program and verify that the command no longer aborts.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.