llvm / llvm/llvm-project

[mlir](remove-dead-values) mlir-opt crashes at Casting.h:644 with `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.

Open
#205,984 2 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: b7c56b5b0a54a6c966a74dfe311fcddcffade521

MLIR Program:
```mlir
module attributes {transform.with_named_sequence} {
func.func @m0() {
%c0 = arith.constant 0 : index
%c0_0 = arith.constant 0 : index
omp.parallel {
cf.br ^bb1(%c0, %c0_0 : index, index)
^bb1(%0: index, %1: index): // 2 preds: ^bb0, ^bb2
%2 = arith.cmpi slt, %0, %1 : index
cf.cond_br %2, ^bb2(%c0_0, %c0_0 : index, index), ^bb3
^bb2(%3: index, %4: index): // pred: ^bb1
cf.br ^bb1(%3, %4 : index, index)
^bb3: // pred: ^bb1
omp.flush
omp.barrier
omp.taskwait
omp.taskyield
omp.terminator
}
return
}
}
```

Reproduce Command: `mlir-opt -remove-dead-values a.mlir`

StackTrace:
```
mlir-opt: /data2/dependency/dev/llvm-project/llvm/include/llvm/Support/Casting.h:644: decltype(auto) llvm::dyn_cast(const From&) [with To = mlir::OpResult; From = mlir::Value]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' 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 -remove-dead-values a.mlir
#0 0x0000556a344531df llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25e71df)
#1 0x0000556a3444f99c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25e399c)
#2 0x0000556a3444fb37 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007faf33d60420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007faf3384b00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007faf3382a859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007faf3382a729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007faf3383bfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000556a3d6938da (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb8278da)
#9 0x0000556a3d657598 mlir::OpTrait::impl::verifyIsIsolatedFromAbove(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb7eb598)
#10 0x0000556a3c4b8131 mlir::Op::verifyRegionInvariants(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa64c131)
#11 0x0000556a3c4c0f41 mlir::RegisteredOperationName::Model::verifyRegionInvariants(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa654f41)
#12 0x0000556a3d69c399 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#13 0x0000556a3d69dd2f mlir::verify(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb831d2f)
#14 0x0000556a3aad46fe mlir::WalkResult llvm::function_ref::callback_fn(long, mlir::Operation*) TransformDialect.cpp:0:0
#15 0x0000556a34538532 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26cc532)
#16 0x0000556a3aad2d0a mlir::transform::TransformDialect::verifyOperationAttribute(mlir::Operation*, mlir::NamedAttribute) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x8c66d0a)
#17 0x0000556a3d699d32 (anonymous namespace)::OperationVerifier::verifyOnEntrance(mlir::Operation&) Verifier.cpp:0:0
#18 0x0000556a3d69c3d0 (anonymous namespace)::OperationVerifier::verifyOperation(mlir::Operation&) Verifier.cpp:0:0
#19 0x0000556a3d69dd2f mlir::verify(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb831d2f)
#20 0x0000556a3d2db5d8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb46f5d8)
#21 0x0000556a3d2db940 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+0xb46f940)
#22 0x0000556a3d2dd9f4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4719f4)
#23 0x0000556a3d2dea81 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb472a81)
#24 0x0000556a3451927b performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x0000556a34519d23 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#26 0x0000556a34519fab 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
#27 0x0000556a3d6b4a75 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+0xb848a75)
#28 0x0000556a345100b4 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#29 0x0000556a3451a4c7 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26ae4c7)
#30 0x0000556a3451a703 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x26ae703)
#31 0x0000556a3437fb2c main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2513b2c)
#32 0x00007faf3382c083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000556a3442f8ce _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x25c38ce)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with mlir-opt -remove-dead-values a.mlir using the MLIR program in the report. Start at the reported verifyIsIsolatedFromAbove and TransformDialect::verifyOperation stack frames, then trace how the remove-dead-values result reaches verification. Done means the reproducer no longer aborts and a regression test covers it.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.