[mlir][affine](affine-super-vectorize) mlir-opt crashes at DecomposeLinalgOps.cpp:363.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: 42f2cd0c980cc1a924619ecaeaa51ca7b55164ab
MLIR Program:
```mlir
module {
func.func @m() {
%alloc = memref.alloc() : memref<1x8x8x64xf32>
%alloc_0 = memref.alloc() : memref<1x18x18x64xf32>
affine.for %arg0 = 0 to 1 {
affine.for %arg1 = 0 to 8 {
affine.for %arg2 = 0 to 64 {
affine.for %arg3 = 0 to 1 {
%0 = affine.load %alloc[%arg0, %arg0, %arg1, %arg2] : memref<1x8x8x64xf32>
%1 = affine.load %alloc_0[%arg0, %arg0 * 2, %arg1 * 2, %arg2] : memref<1x18x18x64xf32>
%2 = arith.cmpf ogt, %0, %1 : f32
%3 = arith.select %2, %0, %1 : f32
affine.store %3, %alloc[%arg0, %arg0, %arg1, %arg2] : memref<1x8x8x64xf32>
}
}
}
}
return
}
}
```
Reproduce Command: `mlir-opt '-affine-super-vectorize=virtual-vector-size=32,256' a.mlir`
StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp:467: mlir::Value mlir::vector::createReadOrMaskedRead(mlir::OpBuilder&, mlir::Location, mlir::Value, const mlir::VectorType&, std::optional, bool, llvm::ArrayRef, mlir::AffineMap): Assertion `(!permutationMap || permutationMap.getNumResults() == static_cast(vecToReadRank)) && "expected permutation map results to match vector rank."' 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 -affine-super-vectorize=virtual-vector-size=32,256 a.mlir
#0 0x000055957b795aff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20adaff)
#1 0x000055957b79265c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20aa65c)
#2 0x000055957b792803 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f656be7f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f656b96a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f656b949859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007f656b949729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007f656b95afd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000055958332c02f mlir::vector::createReadOrMaskedRead(mlir::OpBuilder&, mlir::Location, mlir::Value, mlir::VectorType const&, std::optional, bool, llvm::ArrayRef, mlir::AffineMap) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9c4402f)
#9 0x0000559583062655 vectorizeAffineLoad(mlir::affine::AffineLoadOp, (anonymous namespace)::VectorizationState&) SuperVectorize.cpp:0:0
#10 0x0000559583065ca5 mlir::WalkResult llvm::function_ref::callback_fn, std::allocator>>&, mlir::affine::VectorizationStrategy const&)::'lambda'(mlir::Operation*)>(long, mlir::Operation*) SuperVectorize.cpp:0:0
#11 0x000055957b87b750 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2193750)
#12 0x000055957b87b7d2 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x21937d2)
#13 0x000055957b87b7d2 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x21937d2)
#14 0x000055957b87b7d2 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x21937d2)
#15 0x0000559583062d33 vectorizeLoopNest(std::vector, std::allocator>>&, mlir::affine::VectorizationStrategy const&) SuperVectorize.cpp:0:0
#16 0x0000559583067c57 vectorizeLoops(mlir::Operation*, llvm::DenseSet>&, llvm::ArrayRef, llvm::ArrayRef, llvm::DenseMap, llvm::DenseMapInfo, llvm::detail::DenseMapPair>> const&) SuperVectorize.cpp:0:0
#17 0x0000559583068a38 mlir::affine::vectorizeChildAffineLoops(mlir::Operation*, bool, llvm::ArrayRef, llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9980a38)
#18 0x0000559583069303 (anonymous namespace)::Vectorize::runOnOperation() SuperVectorize.cpp:0:0
#19 0x0000559584cd7f81 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5eff81)
#20 0x0000559584cd8310 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)
#21 0x0000559584cd8bee mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda12'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#22 0x0000559584cd6f7c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5eef7c)
#23 0x0000559584cd7e5b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5efe5b)
#24 0x0000559584cd8310 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)
#25 0x0000559584cda3c4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f23c4)
#26 0x0000559584cdb491 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5f3491)
#27 0x000055957b85bf7b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#28 0x000055957b85cabf processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#29 0x000055957b85cceb 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
#30 0x00005595850bfe55 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)
#31 0x000055957b852d34 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#32 0x000055957b85d207 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2175207)
#33 0x000055957b85d443 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2175443)
#34 0x000055957b6fc9e7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20149e7)
#35 0x00007f656b94b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#36 0x000055957b77248e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x208a48e)
Aborted (core dumped)
```
Contributor guide
Research direction
First run the reported mlir-opt command with the supplied MLIR program to reproduce the assertion. Read vectorizeAffineLoad in SuperVectorize.cpp and the assertion in mlir/lib/Dialect/Vector/Utils/VectorUtils.cpp:467, then trace the affine vectorization path. Done means the reproducer no longer crashes and a regression test covers the failing case.
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
- Needs clarification
- Newbie friendliness
- 48/100