llvm / llvm/llvm-project

[mlir](scf-parallel-loop-specialization) mlir-opt crashes with scf-parallel-loop-specialization

Open
#205,231 3 comments 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: c56e892f5c520b4474158837d7968e5c8dc3e4c1

MLIR Program:
```mlir
#map1 = affine_map<()[s0] -> (s0, 8)>
module {
func.func @m0() -> (f32) {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c10 = arith.constant 10 : index
%cst_2 = arith.constant 0.000000e+00 : f32
%4 = affine.min #map1()[%c10]

%8 = scf.parallel (%arg0) = (%c0) to (%4) step (%c1) init (%cst_2) -> f32 {
%17 = arith.addf %cst_2, %cst_2 : f32
scf.reduce(%17 : f32) {
^bb0(%arg1: f32, %arg2: f32):
%18 = arith.addf %arg1, %arg2 : f32
scf.reduce.return %18 : f32
}
}

return %8 : f32
}
}
```

Reproduce Command: `mlir-opt -scf-parallel-loop-specialization a.mlir`

StackTrace:
```
a.mlir:10:10: error: 'scf.parallel' op operation destroyed but still has uses
%8 = scf.parallel (%arg0) = (%c0) to (%4) step (%c1) init (%cst_2) -> f32 {
^
a.mlir:10:10: note: see current operation:
%0 = "scf.parallel"(<>, <>, <>, <>) <{operandSegmentSizes = array}> ({
^bb0(%arg0: index):
%1 = "arith.addf"(<>, <>) <{fastmath = #arith.fastmath}> : (f32, f32) -> f32
"scf.reduce"(%1) ({
^bb0(%arg1: f32, %arg2: f32):
%2 = "arith.addf"(%arg1, %arg2) <{fastmath = #arith.fastmath}> : (f32, f32) -> f32
"scf.reduce.return"(%2) : (f32) -> ()
}) : (f32) -> ()
}) : (index, index, index, f32) -> f32
a.mlir:19:5: note: - use: "func.return"(<>) : (f32) -> ()

return %8 : f32
^
LLVM ERROR: operation destroyed but still has uses
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 -scf-parallel-loop-specialization a.mlir
#0 0x0000560b2630620f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25cb20f)
#1 0x0000560b263029dc llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c79dc)
#2 0x0000560b26302b77 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f40e05bf420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f40e00aa00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007f40e0089859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x0000560b2622a705 (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24ef705)
#7 0x0000560b262e31e5 (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25a81e5)
#8 0x0000560b2f49e086 mlir::Operation::~Operation() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb763086)
#9 0x0000560b2f49e1cd mlir::Operation::erase() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7631cd)
#10 0x0000560b2d0edc42 specializeParallelLoopForUnrolling(mlir::scf::ParallelOp) LoopSpecialization.cpp:0:0
#11 0x0000560b2d0ee1d3 _ZN4llvm12function_refIFvPN4mlir9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_126ParallelLoopSpecialization14runOnOperationEvEUlNS1_3scf10ParallelOpEE_SE_vEENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S3_ESI_ISJ_PNS1_6RegionEESI_ISJ_PNS1_5BlockEEEE5valuesrSI_IT3_vE5valueESS_E4typeES3_OT1_EUlS3_E_EEvlS3_ LoopSpecialization.cpp:0:0
#12 0x0000560b2d0e8cdc void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (.constprop.3) LoopSpecialization.cpp:0:0
#13 0x0000560b2d0ee065 (anonymous namespace)::ParallelLoopSpecialization::runOnOperation() LoopSpecialization.cpp:0:0
#14 0x0000560b2f11c281 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e1281)
#15 0x0000560b2f11c610 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)
#16 0x0000560b2f11e6c4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e36c4)
#17 0x0000560b2f11f751 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb3e4751)
#18 0x0000560b263cbe8b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x0000560b263cc933 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#20 0x0000560b263ccbbb 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 0x0000560b2f4f4cb5 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)
#22 0x0000560b263c2cc4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#23 0x0000560b263cd0d7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26920d7)
#24 0x0000560b263cd313 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2692313)
#25 0x0000560b26232b8c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x24f7b8c)
#26 0x00007f40e008b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#27 0x0000560b262e291e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25a791e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Start with specializeParallelLoopForUnrolling in LoopSpecialization.cpp, identified by the stack trace, and reproduce the failure with mlir-opt -scf-parallel-loop-specialization a.mlir using the supplied MLIR program. Trace the handling of the scf.parallel result and its return use, then add regression coverage for this reproducer; done means the command completes without the operation-destroyed-with-uses crash.

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
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.