[mlir](gpu-to-llvm) mlir-opt triggers segmentation fault with gpu-to-llvm.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
git version: 3ae0d109f87dedd2a3f5bdf517556ba3d44283d6
MLIR Program:
```mlir
module {
func.func @m0(%arg0: !async.token) attributes {llvm.emit_c_interface} {
return
}
}
```
Reproduce Command: `mlir-opt --gpu-to-llvm a.mlir`
StackTrace:
```
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: mlir-opt --gpu-to-llvm a.mlir
#0 0x0000555c8928449f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x202b49f)
#1 0x0000555c89280c3c llvm::sys::RunSignalHandlers() (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2027c3c)
#2 0x0000555c89280de3 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007f8866103420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x0000555c92829c87 mlir::Type::getContext() const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb5d0c87)
#5 0x0000555c9273de0b mlir::TypeAttr::get(mlir::Type) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb4e4e0b)
#6 0x0000555c917d4ae1 mlir::LLVM::LLVMFuncOp::build(mlir::OpBuilder&, mlir::OperationState&, llvm::StringRef, mlir::Type, mlir::LLVM::linkage::Linkage, bool, mlir::LLVM::cconv::CConv, mlir::SymbolRefAttr, llvm::ArrayRef, llvm::ArrayRef, std::optional) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa57bae1)
#7 0x0000555c9196ee35 mlir::LLVM::LLVMFuncOp::create(mlir::OpBuilder&, mlir::Location, llvm::StringRef, mlir::Type, mlir::LLVM::linkage::Linkage, bool, mlir::LLVM::cconv::CConv, mlir::SymbolRefAttr, llvm::ArrayRef, llvm::ArrayRef, std::optional) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xa715e35)
#8 0x0000555c8e8ee7cc mlir::convertFuncOpToLLVMFuncOp(mlir::FunctionOpInterface, mlir::ConversionPatternRewriter&, mlir::LLVMTypeConverter const&, mlir::SymbolTableCollection*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x76957cc)
#9 0x0000555c8e8f22bf (anonymous namespace)::FuncOpConversion::matchAndRewrite(mlir::func::FuncOp, mlir::func::FuncOpAdaptor, mlir::ConversionPatternRewriter&) const FuncToLLVM.cpp:0:0
#10 0x0000555c89364c2e llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1, mlir::func::FuncOp>(mlir::ConvertOpToLLVMPattern const&, mlir::func::FuncOp, mlir::func::FuncOp::GenericAdaptor>, mlir::ConversionPatternRewriter&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x210bc2e)
#11 0x0000555c89365234 mlir::ConvertOpToLLVMPattern::matchAndRewrite(mlir::Operation*, llvm::ArrayRef, mlir::ConversionPatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x210c234)
#12 0x0000555c923cb2b8 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1722b8)
#13 0x0000555c92412662 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#14 0x0000555c92413bc8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref, llvm::function_ref, llvm::function_ref) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1babc8)
#15 0x0000555c923c5f8b (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#16 0x0000555c923c6476 mlir::OperationConverter::convert(mlir::Operation*, bool) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb16d476)
#17 0x0000555c923d12ba mlir::OperationConverter::applyConversion(llvm::ArrayRef) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb1782ba)
#18 0x0000555c923d2b58 applyConversion(llvm::ArrayRef, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x0000555c923d2d36 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb179d36)
#20 0x0000555c8ad85486 (anonymous namespace)::GpuToLLVMConversionPass::runOnOperation() GPUToLLVMConversion.cpp:0:0
#21 0x0000555c9247e201 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb225201)
#22 0x0000555c9247e590 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+0xb225590)
#23 0x0000555c92480644 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb227644)
#24 0x0000555c924816c1 mlir::PassManager::run(mlir::Operation*) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0xb2286c1)
#25 0x0000555c8934a9bb performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x0000555c8934b4ff processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#27 0x0000555c8934b72b 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
#28 0x0000555c9284f525 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+0xb5f6525)
#29 0x0000555c89341774 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.part.0) MlirOptMain.cpp:0:0
#30 0x0000555c8934bc47 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2c47)
#31 0x0000555c8934be83 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x20f2e83)
#32 0x0000555c891c8bb7 main (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x1f6fbb7)
#33 0x00007f8865bcf083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#34 0x0000555c89260a6e _start (/data2/dependency/dev/llvm-project/build/bin/mlir-opt+0x2007a6e)
Segmentation fault (core dumped)
```
Contributor guide
Research direction
Reproduce the crash with the supplied MLIR program and `mlir-opt --gpu-to-llvm a.mlir`. Trace the conversion path shown in the stack trace, starting with `GPUToLLVMConversion.cpp` and `FuncToLLVM.cpp`. Done means this input no longer causes a segmentation fault and instead completes or reports a diagnostic.
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
- 48/100