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

    <tr>
        <th>Summary</th>
        <td>
            [mlir][openmp] -convert-openmp-to-llvm crashes
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          axeabc
      </td>
    </tr>
</table>

<pre>
    git version: 761bf333e378b52614c

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -convert-openmp-to-llvm a.mlir`

a.mlir:
``` 
func.func @omp_target_update_data_depend(%a: memref<?xf32>) {
  %0 = omp.map.info var_ptr(%a: memref<?xf32>, tensor<?xf32>) map_clauses(to) capture(ByRef) -> memref<?xf32>
  omp.target_update map_entries(%0: memref<?xf32>) {
 omp.terminator
  }
  return
}

``` 
stack trace:

``` 
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-openmp-to-llvm a.mlir
 #0 0x0000562eb81ab128 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d7128)
 #1 0x0000562eb81a8c3e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d4c3e)
 #2 0x0000562eb81ababd SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f98e9647420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000562ebb45fcd3 mlir::Type::getContext() const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x438bcd3)
 #5 0x0000562ebb387f28 mlir::TypeAttr::get(mlir::Type) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42b3f28)
 #6 0x0000562ebab99432 (anonymous namespace)::MapInfoOpConversion::matchAndRewrite(mlir::omp::MapInfoOp, mlir::omp::MapInfoOpAdaptor, mlir::ConversionPatternRewriter&) const OpenMPToLLVM.cpp:0:0
 #7 0x0000562ebab99122 mlir::ConvertOpToLLVMPattern<mlir::omp::MapInfoOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3ac5122)
 #8 0x0000562ebb2fbb11 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4227b11)
 #9 0x0000562ebdc86c91 void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_0>(long) PatternApplicator.cpp:0:0
#10 0x0000562ebdc8394b mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x6baf94b)
#11 0x0000562ebb2fcb53 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#12 0x0000562ebb2fbbb7 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4227bb7)
#13 0x0000562ebb2fcd7f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4228d7f)
#14 0x0000562ebb30496b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x423096b)
#15 0x0000562ebab97395 (anonymous namespace)::ConvertOpenMPToLLVMPass::runOnOperation() OpenMPToLLVM.cpp:0:0
#16 0x0000562ebb29d2d6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c92d6)
#17 0x0000562ebb29dc40 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+0x41c9c40)
#18 0x0000562ebb2a0282 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41cc282)
#19 0x0000562ebb298ab1 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x0000562ebb29870b llvm::LogicalResult llvm::function_ref<llvm::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&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#21 0x0000562ebb3453a5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42713a5)
#22 0x0000562ebb293b35 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41bfb35)
#23 0x0000562ebb293ddf mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41bfddf)
#24 0x0000562ebb29410e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41c010e)
#25 0x0000562eb818bd67 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b7d67)
#26 0x00007f98e8c65083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#27 0x0000562eb818b8ee _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10b78ee)
``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWstu4zoS_RpmQ8SgSD0XXjgPYxpIkCDJ3K3Bl2zOlSgNSaWT_voBJdmWZOfVt90XMxig27ZEqnhO1WGxKIZaq9ZayjmILkB0dUYbt6nMnL5IyvgZq8TrfK0cfJbGqkoDsoBJHLCcECJJkrIIx0HIAboCaNF92lfrZOk7ghj9kzXaNTBIZyicxfDm6RHEaNjbyNpUouESfldu0z9VFsqcV7WD57zSz9K486qWuqzPXXVeFM8lpDPfZWKqv0n6S9_a_oPddd5oPvMfEISoKuuVo2Yt3aqpBXV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