llvm / llvm/llvm-project

[MLIR] Crash During GPU Module Serialization with XeGPU pipeline

Open
#205,510 1 comment 0 reactions 0 assignees View on GitHub
crash mlir:xegpu
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Hi, I encountered a crash when lowering a gpu program using XeGPU pipeline, please review the following program for reproduction.

**Input Program**
```llvm
module attributes {gpu.container_module} {
gpu.module @kernels {
gpu.barrier
}

func.func @main() -> i32 {
%mem = memref.alloca() : memref<10xf32>
%c0_index = arith.constant 0 : index
%cst = arith.constant 3.140000e+00 : f32
memref.store %cst, %mem[%c0_index] : memref<10xf32>
%loaded = memref.load %mem[%c0_index] : memref<10xf32>
%cast = arith.fptosi %loaded : f32 to i32
memref.dealloc %mem : memref<10xf32>
return %cast : i32
}
}
```

**Stack Trace**
```bash
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 input.mlir --gpu-lower-to-xevm-pipeline
#0 0x00005b55c2d45d32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm-project/llvm/lib/Support/Unix/Signals.inc:881:22
#1 0x00005b55c2d461f6 PrintStackTraceSignalHandler(void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:963:1
#2 0x00005b55c2d43568 llvm::sys::RunSignalHandlers() /llvm-project/llvm/lib/Support/Signals.cpp:108:20
#3 0x00005b55c2d455e6 SignalHandler(int, siginfo_t*, void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:448:14
#4 0x000072a336245cb0 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x45cb0)
#5 0x000072a3362a648c pthread_kill (/usr/lib/x86_64-linux-gnu/libc.so.6+0xa648c)
#6 0x000072a336245b7e raise (/usr/lib/x86_64-linux-gnu/libc.so.6+0x45b7e)
#7 0x000072a3362288ec abort (/usr/lib/x86_64-linux-gnu/libc.so.6+0x288ec)
#8 0x00005b55c2d1dc98 bindingsErrorHandler(void*, char const*, bool) /llvm-project/llvm/lib/Support/ErrorHandling.cpp:253:55
#9 0x00005b55d0eb1d92 llvm::Value::~Value() /llvm-project/llvm/lib/IR/Value.cpp:105:19
#10 0x00005b55d0eb0ae4 llvm::User::~User() /llvm-project/llvm/lib/IR/User.cpp:232:1
#11 0x00005b55c8f5629c llvm::Constant::~Constant() /llvm-project/llvm/include/llvm/IR/Constant.h:57:3
#12 0x00005b55c8f562c4 llvm::GlobalValue::~GlobalValue() /llvm-project/llvm/include/llvm/IR/GlobalValue.h:194:3
#13 0x00005b55d0d6b33d llvm::GlobalObject::~GlobalObject() /llvm-project/llvm/lib/IR/Globals.cpp:114:1
#14 0x00005b55d0d65685 llvm::Function::~Function() /llvm-project/llvm/lib/IR/Function.cpp:525:1
#15 0x00005b55c8d85b57 llvm::ilist_alloc_traits::deleteNode(llvm::Function*) /llvm-project/llvm/include/llvm/ADT/ilist.h:42:39
#16 0x00005b55c8d85151 llvm::iplist_impl, llvm::SymbolTableListTraits>::erase(llvm::ilist_iterator, false, false>) /llvm-project/llvm/include/llvm/ADT/ilist.h:206:12
#17 0x00005b55d0e4f3d9 llvm::iplist_impl, llvm::SymbolTableListTraits>::erase(llvm::ilist_iterator, false, false>, llvm::ilist_iterator, false, false>) /llvm-project/llvm/include/llvm/ADT/ilist.h:242:20
#18 0x00005b55d0e4e057 llvm::iplist_impl, llvm::SymbolTableListTraits>::clear() /llvm-project/llvm/include/llvm/ADT/ilist.h:246:41
#19 0x00005b55d0e48210 llvm::Module::~Module() /llvm-project/llvm/lib/IR/Module.cpp:123:18
#20 0x00005b55c4f99f6a std::default_delete::operator()(llvm::Module*) const /mnt/raid/bin/anaconda3/envs/cuda-gcc14/lib/gcc/x86_64-conda-linux-gnu/14.3.0/include/c++/bits/unique_ptr.h:93:2
#21 0x00005b55c4f98f50 std::unique_ptr>::~unique_ptr() /mnt/raid/bin/anaconda3/envs/cuda-gcc14/lib/gcc/x86_64-conda-linux-gnu/14.3.0/include/c++/bits/unique_ptr.h:400:8
#22 0x00005b55cc4985b8 mlir::LLVM::ModuleTranslation::~ModuleTranslation() /llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:806:1
#23 0x00005b55cc4a42d1 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool, llvm::vfs::FileSystem*) /llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:2614:1
#24 0x00005b55c8b86e5c mlir::LLVM::ModuleToObject::translateToLLVMIR(llvm::LLVMContext&) /llvm-project/mlir/lib/Target/LLVM/ModuleToObject.cpp:145:62
#25 0x00005b55c4f95669 (anonymous namespace)::SPIRVSerializer::run() /llvm-project/mlir/lib/Target/LLVM/XeVM/Target.cpp:563:8
#26 0x00005b55c4f95d5b (anonymous namespace)::XeVMTargetAttrImpl::serializeToObject(mlir::Attribute, mlir::Operation*, mlir::gpu::TargetOptions const&) const /llvm-project/mlir/lib/Target/LLVM/XeVM/Target.cpp:639:10
#27 0x00005b55c4f97321 mlir::gpu::detail::TargetAttrInterfaceInterfaceTraits::FallbackModel<(anonymous namespace)::XeVMTargetAttrImpl>::serializeToObject(mlir::gpu::detail::TargetAttrInterfaceInterfaceTraits::Concept const*, mlir::Attribute, mlir::Operation*, mlir::gpu::TargetOptions const&) /llvm-project/build_de045d/tools/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.h.inc:250:1
#28 0x00005b55cfdf2532 mlir::gpu::TargetAttrInterface::serializeToObject(mlir::Operation*, mlir::gpu::TargetOptions const&) const /llvm-project/build_de045d/tools/mlir/include/mlir/Dialect/GPU/IR/CompilationAttrInterfaces.cpp.inc:20:3
#29 0x00005b55c5e392ac (anonymous namespace)::moduleSerializer(mlir::gpu::GPUModuleOp, mlir::gpu::OffloadingLLVMTranslationAttrInterface, mlir::gpu::TargetOptions const&) /llvm-project/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp:97:10
#30 0x00005b55c5e396f5 mlir::gpu::transformGpuModulesToBinaries(mlir::Operation*, mlir::gpu::OffloadingLLVMTranslationAttrInterface, mlir::gpu::TargetOptions const&) /llvm-project/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp:130:19
#31 0x00005b55c5e38fe4 (anonymous namespace)::GpuModuleToBinaryPass::runOnOperation() /llvm-project/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp:74:13
#32 0x00005b55d18d2ff3 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda'()::operator()() const /llvm-project/mlir/lib/Pass/Pass.cpp:613:24
#33 0x00005b55d18dae96 void llvm::function_ref::callback_fn(long) /llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:47:40
#34 0x00005b55c2d67732 llvm::function_ref::operator()() const /llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:62
#35 0x00005b55d18e0a2d void mlir::MLIRContext::executeAction(llvm::function_ref, llvm::ArrayRef, mlir::Pass&) /llvm-project/mlir/include/mlir/IR/MLIRContext.h:297:3
#36 0x00005b55d18d367b mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /llvm-project/mlir/lib/Pass/Pass.cpp:619:23
#37 0x00005b55d18d3ce8 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /llvm-project/mlir/lib/Pass/Pass.cpp:688:15
#38 0x00005b55d18d9869 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /llvm-project/mlir/lib/Pass/Pass.cpp:1128:40
#39 0x00005b55d18d936f mlir::PassManager::run(mlir::Operation*) /llvm-project/mlir/lib/Pass/Pass.cpp:1102:69
#40 0x00005b55c2e4fe8c performActions(llvm::raw_ostream&, std::shared_ptr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:596:13
#41 0x00005b55c2e506d2 processBuffer(llvm::raw_ostream&, std::unique_ptr>, llvm::MemoryBufferRef, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, mlir::SourceMgrDiagnosticVerifierHandler*, llvm::ThreadPoolInterface*) /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:686:26
#42 0x00005b55c2e50ce1 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&)::operator()(std::unique_ptr>, llvm::MemoryBufferRef, llvm::raw_ostream&) const /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:784:25
#43 0x00005b55c2e51ea5 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&) /llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:52
#44 0x00005b55d1e38d15 llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>::operator()(std::unique_ptr>, llvm::MemoryBufferRef const&, llvm::raw_ostream&) const /llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
#45 0x00005b55d1e383de mlir::splitAndProcessBuffer(std::unique_ptr>, llvm::function_ref>, llvm::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) /llvm-project/mlir/lib/Support/ToolUtilities.cpp:30:30
#46 0x00005b55c2e50fab mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:789:47
#47 0x00005b55c2e512db mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:835:13
#48 0x00005b55c2e51499 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:851:21
#49 0x00005b55c2d19901 main /llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:347:32
#50 0x000072a33622a601 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a601)
#51 0x000072a33622a718 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a718)
#52 0x00005b55c2d19435 _start (/mnt/raid/llvm-project/build_de045d/bin/mlir-opt+0x464c435)
Aborted mlir-opt input.mlir --gpu-lower-to-xevm-pipeline
```

**Used Command**
```bash
mlir-opt input.mlir --gpu-lower-to-xevm-pipeline
```

Version: de045d579791d978cce109f9348d20560e112d74

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied input with `mlir-opt input.mlir --gpu-lower-to-xevm-pipeline` and inspect the serialization path in mlir/lib/Target/LLVM/XeVM/Target.cpp, along with ModuleTranslation.cpp and ModuleToObject.cpp from the stack trace. Trace the crash during GPU module serialization and add a regression test using the reproducer; done means the pipeline no longer aborts on this input.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.