google / google/heir

Legalization failure in CGGI Quart conversion

Open
#2,481 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

**Test commit**
[a413796feb31eb6a1e70160308defe4d0250d09e](https://github.com/google/heir/commit/a413796feb31eb6a1e70160308defe4d0250d09e)

**Description**
The `--arith-to-cggi-quart` pass triggers a fatal error when processing `tensor_ext.rotate` operations. The dialect conversion framework reports that `FunctionOpInterfaceSignatureConversion` produced IR that could not be legalized.

**Steps to reproduce**
- Minimal MLIR program (test.mlir)
```
"builtin.module"() ({
"func.func"() <{
function_type = (tensor<4xi8>) -> tensor<4xi8>,
sym_name = "rotate_test"
}> ({
^bb0(%arg0: tensor<4xi8>):
%0 = "arith.constant"() <{value = 1 : i32}> : () -> i32
%1 = "tensor_ext.rotate"(%arg0, %0) : (tensor<4xi8>, i32) -> tensor<4xi8>
"func.return"(%1) : (tensor<4xi8>) -> ()
}) : () -> ()
}) : () -> ()
```

**Command**
```
heir-opt --arith-to-cggi-quart test.mlir
```

**Output**
```
LLVM ERROR: pattern '(anonymous namespace)::FunctionOpInterfaceSignatureConversion' produced IR that could not be legalized. new ops: {}, modified ops: {func.func}, inserted block into ops: {func.func}
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: /workdir/heir/bin/heir-opt --arith-to-cggi-quart test.mlir
#0 0x00005634e96409c6 ___interceptor_backtrace (/workdir/heir/bin/heir-opt+0x5b549c6)
#1 0x00005634f4df91c2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:838:8
#2 0x00005634f4dfa001 llvm::sys::RunSignalHandlers() /proc/self/cwd/external/llvm-project/llvm/lib/Support/Signals.cpp:105:18
#3 0x00005634f4dfa001 SignalHandler(int, siginfo_t*, void*) /proc/self/cwd/external/llvm-project/llvm/lib/Support/Unix/Signals.inc:409:3
#4 0x00007f678ee5d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007f678eeb19fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007f678ee5d476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007f678ee437f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00005634f4d4be78 llvm::report_fatal_error(llvm::Twine const&, bool) /proc/self/cwd/external/llvm-project/llvm/lib/Support/ErrorHandling.cpp:137:5
#9 0x00005634f388b5b6 reportNewIrLegalizationFatalError(mlir::Pattern const&, llvm::SetVector, llvm::DenseSet >, 0u> const&, llvm::SetVector, llvm::DenseSet >, 0u> const&, llvm::SetVector, llvm::DenseSet >, 0u> const&) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:3
#10 0x00005634f388b5b6 (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*)::$_2::operator()(mlir::Pattern const&) const /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2757:9
#11 0x00005634f388b5b6 llvm::LogicalResult llvm::function_ref::callback_fn<(anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*)::$_2>(long, mlir::Pattern const&) /proc/self/cwd/external/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#12 0x00005634f399961e mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::$_0::operator()() const /proc/self/cwd/external/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:229:15
#13 0x00005634f399961e void llvm::function_ref::callback_fn, llvm::function_ref, llvm::function_ref)::$_0>(long) /proc/self/cwd/external/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#14 0x00005634f3995375 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) /proc/self/cwd/external/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:197:5
#15 0x00005634f386ec5c (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2767:21
#16 0x00005634f386ec5c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2533:17
#17 0x00005634f386d170 mlir::OperationConverter::convert(mlir::Operation*) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3288:7
#18 0x00005634f386fa80 mlir::OperationConverter::convertOperations(llvm::ArrayRef) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3385:0
#19 0x00005634f38905af applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode)::$_0::operator()() const /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:4107:9
#20 0x00005634f38905af void llvm::function_ref::callback_fn, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode)::$_0>(long) /proc/self/cwd/external/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#21 0x00005634f387d633 applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) /proc/self/cwd/external/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12
#22 0x00005634f387d95a mlir::applyPartialConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:4120:10
#23 0x00005634f387d95a mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /proc/self/cwd/external/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:4127:10
#24 0x00005634e9743e31 mlir::heir::arith::ArithToCGGIQuart::runOnOperation() /proc/self/cwd/lib/Dialect/Arith/Conversions/ArithToCGGIQuart/ArithToCGGIQuart.cpp:531:16
#25 0x00005634f4120537 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_3::operator()() const /proc/self/cwd/external/llvm-project/mlir/lib/Pass/Pass.cpp:610:22
#26 0x00005634f4120537 void llvm::function_ref::callback_fn(long) /proc/self/cwd/external/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
#27 0x00005634f410e270 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /proc/self/cwd/external/llvm-project/mlir/lib/Pass/Pass.cpp:603:3
#28 0x00005634f410fd95 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /proc/self/cwd/external/llvm-project/mlir/lib/Pass/Pass.cpp:682:9
...
#43 0x00005634e96dcbe1 mlir::asMainReturnCode(llvm::LogicalResult) /proc/self/cwd/external/llvm-project/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h:0:0
#44 0x00005634e96dcbe1 main /proc/self/cwd/tools/heir-opt.cpp:463:10
#45 0x00007f678ee44d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#46 0x00007f678ee44e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#47 0x00005634e95fa025 _start (/workdir/heir/bin/heir-opt+0x5b0e025)
Aborted
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.