<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/77052>77052</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            SparseTensor Dialect test sparse-matmul-2-4-prune.mlir crashed with Assertion 'this->_M_is_engaged()' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Ag-Cu
      </td>
    </tr>
</table>

<pre>
    system: Ubuntu 20.04.6 LTS (Focal Fossa)
current git head: #76697
build command:
`cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
 -DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" \
 -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON`
`cmake --build . --target check-mlir`

reproduced with:
`cd llvm-project/mlir/test/Integration/Dialect/SparseTensor/GPU/CUDA/sm80-lt`
`mlir-opt sparse-matmul-2-4-prune.mlir --sparsifier="enable-gpu-libgen gpu-triple=nvptx64-nvidia-cuda gpu-chip=sm_80 gpu-features=+ptx71 gpu-format=%gpu_compilation_format enable-runtime-library=true"`

will get:
`/usr/include/c++/9/optional:438: constexpr _Tp& std::_Optional_base_impl<_Tp, _Dp>::_M_get() [with _Tp = mlir::gpu::CompilationTarget; _Dp = std::_Optional_base<mlir::gpu::CompilationTarget, true, true>]: Assertion 'this->_M_is_engaged()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: mlir-opt sparse-matmul-2-4-prune.mlir "--sparsifier=enable-gpu-libgen gpu-triple=nvptx64-nvidia-cuda gpu-chip=sm_80 gpu-features=+ptx71 gpu-format=%gpu_compilation_format enable-runtime-library=true"
 #0 0x00005581a18a2bcf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (.localalias) (/home/yt/llvm-project/build/bin/mlir-opt+0x1685bcf)
 #1 0x00005581a189fc24 SignalHandler(int) (/home/yt/llvm-project/build/bin/mlir-opt+0x1682c24)
 #2 0x00007fe7d4206420 __restore_rt (/usr/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fe7d3ca300b raise (/usr/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fe7d3c82859 abort (/usr/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00005581a201ec2b (anonymous namespace)::GpuModuleToBinaryPass::runOnOperation() (/home/yt/llvm-project/build/bin/mlir-opt+0x1e01c2b)
 #6 0x00005581a459d3ae mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (.localalias) (/home/yt/llvm-project/build/bin/mlir-opt+0x43803ae)
 #7 0x00005581a459d88a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.localalias) (/home/yt/llvm-project/build/bin/mlir-opt+0x438088a)
 #8 0x00005581a459e054 mlir::PassManager::run(mlir::Operation*) (/home/yt/llvm-project/build/bin/mlir-opt+0x4381054)
 #9 0x00005581a458ed43 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/home/yt/llvm-project/build/bin/mlir-opt+0x4371d43)
#10 0x00005581a45902c4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) (/home/yt/llvm-project/build/bin/mlir-opt+0x43732c4)
#11 0x00005581a4590474 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) (/home/yt/llvm-project/build/bin/mlir-opt+0x4373474)
#12 0x00005581a468c964 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/home/yt/llvm-project/build/bin/mlir-opt+0x446f964)
#13 0x00005581a45888d7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (.localalias) (/home/yt/llvm-project/build/bin/mlir-opt+0x436b8d7)
#14 0x00005581a45905c1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (.localalias) (/home/yt/llvm-project/build/bin/mlir-opt+0x43735c1)
#15 0x00005581a4590a46 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/yt/llvm-project/build/bin/mlir-opt+0x4373a46)
#16 0x00005581a17d9293 main (/home/yt/llvm-project/build/bin/mlir-opt+0x15bc293)
#17 0x00007fe7d3c84083 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#18 0x00005581a18725fe _start (/home/yt/llvm-project/build/bin/mlir-opt+0x16555fe)
Aborted`

I don't know if this is a bug or if I'm missing some depend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