llvm / llvm/llvm-project

[mlir] -inline implement handleTerminator bug report

Open
#206,083 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: 81a8c66fdc96a7bf6927bf3f88d4b2e24a5c71e7

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -inline a.mlir`

a.mlir:

```mlir
module {
llvm.func @atanh_vec_f32(%arg0: vector<8xf32>) {
%0 = math.atanh %arg0 : vector<8xf32>
vector.yield %arg0 : vector<8xf32>
}
llvm.func @_mlir_ciface_atanh_vec_f32(%arg0: vector<8xf32>) attributes {llvm.emit_c_interface} {
llvm.call @atanh_vec_f32(%arg0) : (vector<8xf32>) -> ()
llvm.return
}
}

```

stack trace:

```
must implement handleTerminator in the case of one inlined block
UNREACHABLE executed at /data/szy/MLIR/llvm-release/llvm-project/build/tools/mlir/include/mlir/Transforms/DialectInlinerInterface.h.inc:82!
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 -inline 74.mlir
#0 0x0000561f7012a0c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20360c8)
#1 0x0000561f70126f61 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2032f61)
#2 0x0000561f7012b1e6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f6dcc2a2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007f6dcb8df00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007f6dcb8be859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x0000561f7011057f (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201c57f)
#7 0x0000561f720b9779 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3fc5779)
#8 0x0000561f78a980ef inlineRegionImpl(mlir::InlinerInterface&, llvm::function_ref, mlir::Region*, mlir::Block*, llvm::ilist_iterator, false, false>, mlir::IRMapping&, mlir::ValueRange, mlir::TypeRange, std::optional, bool, mlir::CallOpInterface) InliningUtils.cpp:0:0
#9 0x0000561f78a98e3a mlir::inlineCall(mlir::InlinerInterface&, llvm::function_ref, mlir::CallOpInterface, mlir::CallableOpInterface, mlir::Region*, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9a4e3a)
#10 0x0000561f78a94a99 mlir::Inliner::Impl::inlineSCC((anonymous namespace)::InlinerInterfaceImpl&, (anonymous namespace)::CGUseList&, (anonymous namespace)::CallGraphSCC&, mlir::MLIRContext*) Inliner.cpp:0:0
#11 0x0000561f78a8e85a mlir::Inliner::doInlining() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa99a85a)
#12 0x0000561f78a13f3c (anonymous namespace)::InlinerPass::runOnOperation() InlinerPass.cpp:0:0
#13 0x0000561f78b12662 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa1e662)
#14 0x0000561f78b134a4 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+0xaa1f4a4)
#15 0x0000561f78b1a3ba mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa263ba)
#16 0x0000561f78b19cef mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xaa25cef)
#17 0x0000561f701d93c0 performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x0000561f701d85f6 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 0x0000561f78e65e55 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+0xad71e55)
#20 0x0000561f701cf656 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20db656)
#21 0x0000561f701cfa35 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20dba35)
#22 0x0000561f701cfd95 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x20dbd95)
#23 0x0000561f7010fb52 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201bb52)
#24 0x00007f6dcb8c0083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x0000561f7010f68e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x201b68e)
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Run mlir-opt -inline on the supplied a.mlir reproducer and inspect the assertion in DialectInlinerInterface.h.inc, then trace the inlining path through InliningUtils.cpp and Inliner.cpp. Add a regression test for this reproducer and verify that the inline pass completes without the handleTerminator crash.

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
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.