llvm / llvm/llvm-project

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

Open
#207,350 1 comment 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_add_1() -> i32 "None" {
%cst1_i32 = spirv.Constant 1 : i32
%0 = test.with_bounds {smax = 0 : si32, smin = 0 : si32, umax = 0 : i32, umin = 0 : ui32} : i32
%1 = builtin.unrealized_conversion_cast %cst1_i32 : i32 to i32
%2 = spirv.IAdd %0, %1 : i32
%3 = builtin.unrealized_conversion_cast %2 : i32 to i32
%4 = test.reflect_bounds %3 : i32
%5 = builtin.unrealized_conversion_cast %4 : i32 to i32
spirv.ReturnValue %5 : 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 108.mlir
#0 0x000055db0903a7bb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20127bb)
#1 0x000055db09037621 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x200f621)
#2 0x000055db0903b8e6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f932a486420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x000055db0e303e8a mlir::WalkResult llvm::function_ref::callback_fn(long, mlir::Operation*) SPIRVOps.cpp:0:0
#5 0x000055db090fca97 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 0x000055db0e2fa06d mlir::spirv::FuncOp::verifyBody() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x72d206d)
#7 0x000055db0dd2de27 llvm::LogicalResult mlir::function_interface_impl::verifyTrait(mlir::spirv::FuncOp) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6d05e27)
#8 0x000055db0dd2d528 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 0x000055db0dd2949e mlir::RegisteredOperationName::Model::verifyInvariants(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6d0149e)
#10 0x000055db1211ca0e (anonymous namespace)::OperationVerifier::verifyOpAndDominance(mlir::Operation&) Verifier.cpp:0:0
#11 0x000055db1211b61f mlir::verify(mlir::Operation*, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xb0f361f)
#12 0x000055db11ffedca mlir::AsmState::AsmState(mlir::Operation*, mlir::OpPrintingFlags const&, llvm::DenseMap, llvm::DenseMapInfo, llvm::detail::DenseMapPair>>*, mlir::FallbackAsmResourceMap*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xafd6dca)
#13 0x000055db12007776 mlir::Operation::print(llvm::raw_ostream&, mlir::OpPrintingFlags const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xafdf776)
#14 0x000055db120899ad mlir::Diagnostic::appendOp(mlir::Operation&, mlir::OpPrintingFlags const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xb0619ad)
#15 0x000055db12089878 mlir::Diagnostic::operator<<(mlir::Operation&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xb061878)
#16 0x000055db11d22c16 mlir::OperationConverter::applyConversion(llvm::ArrayRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xacfac16)
#17 0x000055db11d2f529 void llvm::function_ref::callback_fn, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode)::$_0>(long) DialectConversion.cpp:0:0
#18 0x000055db11d26597 applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x000055db11d2667b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xacfe67b)
#20 0x000055db092080af (anonymous namespace)::TestUnknownRootOpDriver::runOnOperation() TestPatterns.cpp:0:0
#21 0x000055db11dc70b8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad9f0b8)
#22 0x000055db11dc8094 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)
#23 0x000055db11dcf11a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xada711a)
#24 0x000055db11dce9df mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xada69df)
#25 0x000055db090e97f0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x000055db090e8a26 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
#27 0x000055db1212f176 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)
#28 0x000055db090dfb76 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)
#29 0x000055db090dff5a mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20b7f5a)
#30 0x000055db090e02b5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20b82b5)
#31 0x000055db090200c2 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1ff80c2)
#32 0x00007f9329aa4083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x000055db0901fbfe _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

Run mlir-opt -test-legalize-unknown-root-patterns with the provided a.mlir reproducer and confirm the segmentation fault. Read TestPatterns.cpp and the SPIR-V function verification path shown in SPIRVOps.cpp, then trace the interaction with dialect conversion. Done means the reproducer no longer crashes and a regression test covers the failing case.

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
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.