llvm / llvm/llvm-project

[MLIR](test-scf-parallel-loop-collapsing{collapsed-indices-0=0,1}) mlir-opt crashes with test-scf-parallel-loop-collapsing{collapsed-indices-0=0,1}

Open
#216,218 1 comment 0 reactions 0 assignees View on GitHub
crash generated by fuzzer mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

git version: 3ae0d109f87dedd2a3f5bdf517556ba3d44283d6

MLIR Program:
```mlir
module {
func.func @test_parallel_collapse() {
%c0 = arith.constant 0 : index
%c10 = arith.constant 10 : index
%c1 = arith.constant 1 : index
%0 = scf.parallel (%arg0, %arg1) = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) init (%c0) -> index {
%4 = arith.addi %arg0, %arg1 : index
scf.reduce(%4 : index) {
^bb0(%arg2: index, %arg3: index):
%5 = arith.addi %arg2, %arg3 : index
scf.reduce.return %5 : index
}
}
%2 = arith.addi %0, %0 : index
return
}
}
```

Reproduce Command: `mlir-opt -pass-pipeline="builtin.module(test-scf-parallel-loop-collapsing{collapsed-indices-0=0,1})" a.mlir`

StackTrace:
```
a.mlir:6:10: error: 'scf.parallel' op operation destroyed but still has uses
%0 = scf.parallel (%arg0, %arg1) = (%c0, %c0) to (%c10, %c10) step (%c1, %c1) init (%c0) -> index {
^
a.mlir:6:10: note: see current operation:
%0 = "scf.parallel"(<>, <>, <>, <>, <>, <>, <>) <{operandSegmentSizes = array}> ({
^bb0(%arg0: index, %arg1: index):
}) : (index, index, index, index, index, index, index) -> index
a.mlir:16:10: note: - use: %10 = "arith.addi"(<>, <>) <{overflowFlags = #arith.overflow}> : (index, index) -> index

%2 = arith.addi %0, %0 : index
^
a.mlir:16:10: note: - use: %10 = "arith.addi"(<>, <>) <{overflowFlags = #arith.overflow}> : (index, index) -> index

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: mlir-opt -pass-pipeline=builtin.module(test-scf-parallel-loop-collapsing{collapsed-indices-0=0,1}) a.mlir
#0 0x000056099dd1849f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x202b49f)
#1 0x000056099dd14c3c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2027c3c)
#2 0x000056099dd14de3 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007fcf800ef420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fcf7fbda00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fcf7fbb9859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x000056099dc546c5 (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f676c5)
#7 0x000056099dcf5335 (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2008335)
#8 0x00005609a728c97e mlir::Operation::~Operation() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb59f97e)
#9 0x00005609a728cacd mlir::Operation::erase() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb59facd)
#10 0x00005609a537b253 mlir::collapseParallelLoops(mlir::RewriterBase&, mlir::scf::ParallelOp, llvm::ArrayRef>>) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x968e253)
#11 0x00005609a4d55228 (anonymous namespace)::TestSCFParallelLoopCollapsing::runOnOperation()::'lambda'(mlir::scf::ParallelOp)::operator()(mlir::scf::ParallelOp) const ParallelLoopCollapsing.cpp:0:0
#12 0x00005609a4d554b3 _ZN4llvm12function_refIFvPN4mlir9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_129TestSCFParallelLoopCollapsing14runOnOperationEvEUlNS1_3scf10ParallelOpEE_SE_vEENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S3_ESI_ISJ_PNS1_6RegionEESI_ISJ_PNS1_5BlockEEEE5valuesrSI_IT3_vE5valueESS_E4typeES3_OT1_EUlS3_E_EEvlS3_ ParallelLoopCollapsing.cpp:0:0
#13 0x00005609a4d5460c void mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (.constprop.0) ParallelLoopCollapsing.cpp:0:0
#14 0x00005609a4d56008 (anonymous namespace)::TestSCFParallelLoopCollapsing::runOnOperation() ParallelLoopCollapsing.cpp:0:0
#15 0x00005609a6f12201 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb225201)
#16 0x00005609a6f12590 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+0xb225590)
#17 0x00005609a6f14644 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb227644)
#18 0x00005609a6f156c1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2286c1)
#19 0x000056099ddde9bb performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x000056099dddf4ff processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#21 0x000056099dddf72b 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
#22 0x00005609a72e3525 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+0xb5f6525)
#23 0x000056099ddd5774 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#24 0x000056099dddfc47 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2c47)
#25 0x000056099dddfe83 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2e83)
#26 0x000056099dc5cbb7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f6fbb7)
#27 0x00007fcf7fbbb083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#28 0x000056099dcf4a6e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2007a6e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the provided mlir-opt pipeline and MLIR input, then inspect collapseParallelLoops and the TestSCFParallelLoopCollapsing entry point in ParallelLoopCollapsing.cpp. Done means this input no longer aborts with an operation-destroyed-with-uses error while the parallel-loop collapsing behavior remains valid.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.