[mlir](AffineDelinearizeIndexOp::fold) mlir-opt crashes at MathExtras.h:450 with assertion `Denominator >= 1 && "Mod by non-positive number"' failed.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: c56e892f5c520b4474158837d7968e5c8dc3e4c1
MLIR Program:
```mlir
module {
func.func @m1() {
%c16 = arith.constant 16 : index
%c224 = arith.constant 224 : index
%c224_0 = arith.constant 224 : index
%2:3 = affine.delinearize_index %c16 into (%c16, %c224, %c224) : index, index, index
%3:3 = affine.delinearize_index %c16 into (%c16, %2#0, %c224) : index, index, index
%4:3 = affine.delinearize_index %c16 into (%c16, %3#1, %c224_0) : index, index, index
return
}
}
```
Reproduce Command: `mlir-opt --affine-fold-memref-alias-ops a.mlir`
StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/llvm/include/llvm/Support/MathExtras.h:450: constexpr T llvm::mod(U, V) [with U = long int; V = long int; T = long int]: Assertion `Denominator >= 1 && "Mod by non-positive number"' 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: /data2/dependency/dev/llvm-project/build/bin/mlir-opt -affine-fold-memref-alias-ops a.mlir
#0 0x0000565029cd220f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cb20f)
#1 0x0000565029cce9dc llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c79dc)
#2 0x0000565029cceb77 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fafeea53420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fafee53e00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fafee51d859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fafee51d729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fafee52efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x000056503265ca8b mlir::affine::AffineDelinearizeIndexOp::fold(mlir::affine::AffineDelinearizeIndexOpGenericAdaptor>, llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf55a8b)
#9 0x000056503265cb8d llvm::LogicalResult llvm::detail::UniqueFunctionBase, llvm::SmallVectorImpl&>::CallImpl::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::OpTrait::Elementwise, mlir::InferIntDivisibilityOpInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef, llvm::SmallVectorImpl&) const>(void*, mlir::Operation*, llvm::ArrayRef, llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xaf55b8d)
#10 0x00005650326a9c86 mlir::RegisteredOperationName::Model::foldHook(mlir::Operation*, llvm::ArrayRef, llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xafa2c86)
#11 0x0000565032e69754 mlir::Operation::fold(llvm::ArrayRef, llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb762754)
#12 0x0000565032e69a80 mlir::Operation::fold(llvm::SmallVectorImpl&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb762a80)
#13 0x0000565032a48366 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#14 0x0000565032a4c446 mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb345446)
#15 0x0000565031076ebf (anonymous namespace)::AffineFoldMemRefAliasOpsPass::runOnOperation() FoldMemRefAliasOps.cpp:0:0
#16 0x0000565032ae8281 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e1281)
#17 0x0000565032ae8610 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+0xb3e1610)
#18 0x0000565032aea6c4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e36c4)
#19 0x0000565032aeb751 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e4751)
#20 0x0000565029d97e8b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x0000565029d98933 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#22 0x0000565029d98bbb 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
#23 0x0000565032ec0cb5 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+0xb7b9cb5)
#24 0x0000565029d8ecc4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#25 0x0000565029d990d7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26920d7)
#26 0x0000565029d99313 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2692313)
#27 0x0000565029bfeb8c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24f7b8c)
#28 0x00007fafee51f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x0000565029cae91e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25a791e)
Aborted (core dumped)
```
Contributor guide
Research direction
Reproduce the crash with the supplied MLIR program and `mlir-opt --affine-fold-memref-alias-ops a.mlir`. Start at `AffineDelinearizeIndexOp::fold`, then inspect the assertion in `llvm/include/llvm/Support/MathExtras.h:450` and the `FoldMemRefAliasOps.cpp` pass entry point. Done means the reproducer no longer aborts during folding.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100