llvm / llvm/llvm-project

[mlir][affine](affine-loop-fusion) mlir-opt crash at Affine/Analysis/Utils.cpp:256

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

Description

git version: 7ece48b9e5bb7aafdcc53aa2445328a67b501d24

MLIR Program:
```mlir
module {
func.func @m() {
%alloc = memref.alloc() : memref<10xf32>
%alloc_1 = memref.alloc() : memref<10xf32>
affine.for %arg0 = 0 to 10 step 128 {
%1 = ub.poison : f32
%2 = vector.transfer_read %alloc_1[%arg0], %1 : memref<10xf32>, vector<128xf32>
vector.transfer_write %2, %alloc[%arg0] : vector<128xf32>, memref<10xf32>
}
affine.for %arg0 = 0 to 10 step 128 {
%1 = ub.poison : f32
%2 = vector.transfer_read %alloc[%arg0], %1 : memref<10xf32>, vector<128xf32>
}
return
}
}
```

Reproduce Command: `mlir-opt --affine-loop-fusion a.mlir`

StackTrace:
```
unexpected op
UNREACHABLE executed at /data2/dependency/dev/llvm-project/mlir/lib/Dialect/Affine/Analysis/Utils.cpp:256!
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-loop-fusion a.mlir
#0 0x000055fc26735ddf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20bfddf)
#1 0x000055fc2673294c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20bc94c)
#2 0x000055fc26732af3 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f6c6f92b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f6c6f41600b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f6c6f3f5859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x000055fc2671336e (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x209d36e)
#7 0x000055fc2e30dea8 getMemRef(mlir::Operation*) Utils.cpp:0:0
#8 0x000055fc2e30e134 mayDependence(mlir::affine::MemRefDependenceGraph::Node const&, mlir::affine::MemRefDependenceGraph::Node const&, mlir::Value)::'lambda'(llvm::ArrayRef, llvm::ArrayRef)::operator()(llvm::ArrayRef, llvm::ArrayRef) const::'lambda'(mlir::Operation*)::operator()(mlir::Operation*) const (.isra.0) Utils.cpp:0:0
#9 0x000055fc2e30e41c mlir::Operation* const* std::__find_if, llvm::ArrayRef)::operator()(llvm::ArrayRef, llvm::ArrayRef) const::'lambda'(mlir::Operation*)>>(mlir::Operation* const*, mlir::Operation* const*, __gnu_cxx::__ops::_Iter_pred, llvm::ArrayRef)::operator()(llvm::ArrayRef, llvm::ArrayRef) const::'lambda'(mlir::Operation*)>, std::random_access_iterator_tag) (.isra.0) Utils.cpp:0:0
#10 0x000055fc2e3202d8 mlir::affine::MemRefDependenceGraph::init(bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x9caa2d8)
#11 0x000055fc2e0092b5 (anonymous namespace)::LoopFusion::runOnBlock(mlir::Block*) LoopFusion.cpp:0:0
#12 0x000055fc2e009f61 void llvm::function_ref::callback_fn<(anonymous namespace)::LoopFusion::runOnOperation()::'lambda'(mlir::Operation*)>(long, mlir::Operation*) LoopFusion.cpp:0:0
#13 0x000055fc2e009c21 (anonymous namespace)::LoopFusion::runOnOperation() LoopFusion.cpp:0:0
#14 0x000055fc2fca1581 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb62b581)
#15 0x000055fc2fca1910 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+0xb62b910)
#16 0x000055fc2fca39c4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb62d9c4)
#17 0x000055fc2fca4a41 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb62ea41)
#18 0x000055fc267fc17b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x000055fc267fccbf processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#20 0x000055fc267fceeb 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
#21 0x000055fc300862b5 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+0xba102b5)
#22 0x000055fc267f2f34 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#23 0x000055fc267fd407 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2187407)
#24 0x000055fc267fd643 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2187643)
#25 0x000055fc2669ca97 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2026a97)
#26 0x00007f6c6f3f7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#27 0x000055fc2671277e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x209c77e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with mlir-opt --affine-loop-fusion a.mlir using the MLIR program in the issue. Start at mlir/lib/Dialect/Affine/Analysis/Utils.cpp:256, then trace the callers through LoopFusion.cpp. Done means this input no longer aborts and regression coverage verifies the corrected 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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.