[mlir] affine-loop-fusion crashes at lib/Dialect/Affine/Analysis/Utils.cpp:256 with unexpected op. UNREACHABLE bug report
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: 81a8c66fdc96a7bf6927bf3f88d4b2e24a5c71e7
system: `Ubuntu 18.04.6 LTS`
reproduce with: `mlir-opt -affine-loop-fusion=maximal a.mlir`
a.mlir:
```mlir
module {
func.func @test_vectorize_unsupported(%arg0: memref<8xf32>, %arg1: memref<8xf32>) {
%0 = builtin.unrealized_conversion_cast %arg1 : memref<8xf32> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
%cst = arith.constant 0.000000e+00 : f32
%c0 = arith.constant 0 : index
%1 = builtin.unrealized_conversion_cast %c0 : index to i64
affine.for %arg2 = 0 to 8 {
%2 = builtin.unrealized_conversion_cast %arg2 : index to i64
%3 = llvm.extractvalue %0[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
%4 = llvm.getelementptr %3[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32
%5 = llvm.load %4 : !llvm.ptr -> f32
affine.store %5, %arg1[%c0] : memref<8xf32>
}
affine.for %arg2 = 0 to 8 {
%2 = builtin.unrealized_conversion_cast %arg2 : index to i64
%3 = llvm.extractvalue %0[1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
%4 = llvm.getelementptr %3[%2] : (!llvm.ptr, i64) -> !llvm.ptr, f32
%5 = llvm.load %4 : !llvm.ptr -> f32
affine.store %5, %arg1[%c0] : memref<8xf32>
}
return
}
}
```
stack trace:
```
unexpected op
UNREACHABLE executed at /data/szy/MLIR/llvm-release/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: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -affine-loop-fusion=maximal 72.mlir
#0 0x000055ef43de20c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20360c8)
#1 0x000055ef43ddef61 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2032f61)
#2 0x000055ef43de31e6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fcb50c28420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fcb5026500b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007fcb50244859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x000055ef43dc857f (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201c57f)
#7 0x000055ef4b01124c (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x926524c)
#8 0x000055ef4b010f69 bool __gnu_cxx::__ops::_Iter_pred, llvm::ArrayRef) const::'lambda'(mlir::Operation*)>::operator()(mlir::Operation* const*) Utils.cpp:0:0
#9 0x000055ef4affaab6 mlir::affine::MemRefDependenceGraph::init(bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x924eab6)
#10 0x000055ef4ad68a36 void llvm::function_ref::callback_fn<(anonymous namespace)::LoopFusion::runOnOperation()::$_0>(long, mlir::Operation*) LoopFusion.cpp:0:0
#11 0x000055ef43ea3f0e void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20f7f0e)
#12 0x000055ef4ad664da (anonymous namespace)::LoopFusion::runOnOperation() LoopFusion.cpp:0:0
#13 0x000055ef4c7ca662 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa1e662)
#14 0x000055ef4c7cb4a4 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa1f4a4)
#15 0x000055ef4c7d23ba mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa263ba)
#16 0x000055ef4c7d1cef mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa25cef)
#17 0x000055ef43e913c0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055ef43e905f6 llvm::LogicalResult llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::callback_fn>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#19 0x000055ef4cb1de55 mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad71e55)
#20 0x000055ef43e87656 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20db656)
#21 0x000055ef43e87a35 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20dba35)
#22 0x000055ef43e87d95 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20dbd95)
#23 0x000055ef43dc7b52 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201bb52)
#24 0x00007fcb50246083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x000055ef43dc768e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201b68e)
Aborted (core dumped)
```
Contributor guide
Research direction
Start by reproducing the crash with `mlir-opt -affine-loop-fusion=maximal a.mlir`, then inspect `lib/Dialect/Affine/Analysis/Utils.cpp:256` and the affine loop-fusion path named in the stack trace. Done means the provided input no longer aborts with `UNREACHABLE` when the pass runs.
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
- 52/100