llvm / llvm/llvm-project

[mlir] -test-legalize-unknown-root-patterns bug report

Open
#207,353 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: b3d0b1f0415deda8d5f427ff009a72b558532b99

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -test-legalize-unknown-root-patterns a.mlir`

a.mlir:

```mlir
module {
spirv.func @test_muli() -> i32 "None" {
%0 = "emitc.constant"() <{value = 1 : i32}> : () -> i32
%1 = test.with_bounds {smax = 0 : si32, smin = 0 : si32, umax = 0 : ui32, umin = 0 : ui32} : i32
%2 = arith.muli %1, %0 : i32
%3 = test.reflect_bounds %2 : i32
%4 = builtin.unrealized_conversion_cast %3 : i32 to i32
spirv.ReturnValue %4 : i32
}
}

```

stack trace:

```
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 -test-legalize-unknown-root-patterns 110.mlir
#0 0x0000562cda0137bb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20127bb)
#1 0x0000562cda010621 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x200f621)
#2 0x0000562cda0148e6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f9d232a4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x0000562cdf2dce8a mlir::WalkResult llvm::function_ref::callback_fn(long, mlir::Operation*) SPIRVOps.cpp:0:0
#5 0x0000562cda0d5a97 mlir::WalkResult mlir::detail::walk(mlir::Operation*, llvm::function_ref, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20d4a97)
#6 0x0000562cdf2d306d mlir::spirv::FuncOp::verifyBody() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x72d206d)
#7 0x0000562cded06e27 llvm::LogicalResult mlir::function_interface_impl::verifyTrait(mlir::spirv::FuncOp) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6d05e27)
#8 0x0000562cded06528 mlir::Op, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface, mlir::OpTrait::TraitBase>::Trait, mlir::detail::Interface, mlir::OpTrait::TraitBase>::Trait>::verifyInvariants(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6d05528)
#9 0x0000562cded0249e mlir::RegisteredOperationName::Model::verifyInvariants(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6d0149e)
#10 0x0000562ce30f5a0e (anonymous namespace)::OperationVerifier::verifyOpAndDominance(mlir::Operation&) Verifier.cpp:0:0
#11 0x0000562ce30f5470 (anonymous namespace)::OperationVerifier::verifyOpAndDominance(mlir::Operation&) Verifier.cpp:0:0
#12 0x0000562ce30f461f mlir::verify(mlir::Operation*, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xb0f361f)
#13 0x0000562ce2da0512 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad9f512)
#14 0x0000562ce2da1094 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+0xada0094)
#15 0x0000562ce2da811a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xada711a)
#16 0x0000562ce2da79df mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xada69df)
#17 0x0000562cda0c27f0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x0000562cda0c1a26 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 0x0000562ce3108176 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+0xb107176)
#20 0x0000562cda0b8b76 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20b7b76)
#21 0x0000562cda0b8f5a mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20b7f5a)
#22 0x0000562cda0b92b5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20b82b5)
#23 0x0000562cd9ff90c2 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1ff80c2)
#24 0x00007f9d228c2083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x0000562cd9ff8bfe _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1ff7bfe)
Segmentation fault (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

First reproduce the crash with mlir-opt -test-legalize-unknown-root-patterns and the provided a.mlir input. Trace from SPIRVOps.cpp and FuncOp::verifyBody(), which appear in the stack trace, then check how this verifier handles the operations shown. Done means the reproducer no longer segfaults and regression coverage confirms the behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.