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

    <tr>
        <th>Summary</th>
        <td>
            [MLIR][LLVM] Fails to lower to LLVM IR
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```llvm
module attributes {llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
  llvm.mlir.global internal @_ZN3c10L12trivial_initE() : !llvm.struct<(i8)> {
    %0 = llvm.mlir.constant(1 : i64) : i64
    %1 = llvm.alloca %0 x !llvm.struct<(i8)> : (i64) -> !llvm.ptr<struct<(i8)>>
    %2 = llvm.load %1 : !llvm.ptr<struct<(i8)>>
    llvm.return %2 : !llvm.struct<(i8)>
  }
}
```

```
$ ~/git/Polygeist/mlir-build/bin/mlir-translate glob.mlir --mlir-to-llvmir
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/wmoses/git/Polygeist/mlir-build/bin/mlir-translate glob.mlir --mlir-to-llvmir
 #0 0x00005608f19787f4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/wmoses/git/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
 #1 0x00005608f19788ab PrintStackTraceSignalHandler(void*) /home/wmoses/git/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
 #2 0x00005608f197655a llvm::sys::RunSignalHandlers() /home/wmoses/git/Polygeist/llvm-project/llvm/lib/Support/Signals.cpp:97:0
 #3 0x00005608f1978175 SignalHandler(int) /home/wmoses/git/Polygeist/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0
 #4 0x00007f91671be980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #5 0x00005608f06130be llvm::BasicBlock::getParent() const /home/wmoses/git/Polygeist/llvm-project/llvm/include/llvm/IR/BasicBlock.h:107:0
 #6 0x00005608f1549912 llvm::BasicBlock::getModule() const /home/wmoses/git/Polygeist/llvm-project/llvm/lib/IR/BasicBlock.cpp:148:0
 #7 0x00005608f050b886 llvm::BasicBlock::getModule() /home/wmoses/git/Polygeist/llvm-project/llvm/include/llvm/IR/BasicBlock.h:118:0
 #8 0x00005608f052ff03 llvm::IRBuilderBase::CreateAlloca(llvm::Type*, unsigned int, llvm::Value*, llvm::Twine const&) /home/wmoses/git/Polygeist/llvm-project/llvm/include/llvm/IR/IRBuilder.h:1630:0
 #9 0x00005608f0519f5e convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) /home/wmoses/git/Polygeist/mlir-build/tools/mlir/include/mlir/Dialect/LLVMIR/LLVMConversions.inc:17:0
#10 0x00005608f0528e87 (anonymous namespace)::LLVMDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp:500:0
#11 0x00005608f0b884ba mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&) /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:480:0
#12 0x00005608f0b8916b mlir::LLVM::ModuleTranslation::convertGlobals() /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:615:0
#13 0x00005608f0b8c0be mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:1043:0
#14 0x00005608efec09be mlir::registerToLLVMIRTranslation()::'lambda'(mlir::ModuleOp, llvm::raw_ostream&)::operator()(mlir::ModuleOp, llvm::raw_ostream&) const /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp:29:0
#15 0x00005608efec0cb1 std::_Function_handler<mlir::LogicalResult (mlir::ModuleOp, llvm::raw_ostream&), mlir::registerToLLVMIRTranslation()::'lambda'(mlir::ModuleOp, llvm::raw_ostream&)>::_M_invoke(std::_Any_data const&, mlir::ModuleOp&&, llvm::raw_ostream&) /usr/include/c++/7/bits/std_function.h:303:0
#16 0x00005608f045a3af std::function<mlir::LogicalResult (mlir::ModuleOp, llvm::raw_ostream&)>::operator()(mlir::ModuleOp, llvm::raw_ostream&) const /usr/include/c++/7/bits/std_function.h:707:0
#17 0x00005608f0457c1b mlir::TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(llvm::StringRef, std::function<mlir::LogicalResult (mlir::ModuleOp, llvm::raw_ostream&)> const&, std::function<void (mlir::DialectRegistry&)> const&)::'lambda'(llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*)::operator()(llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*) const /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Translation/Translation.cpp:107:0
#18 0x00005608f0459009 std::_Function_handler<mlir::LogicalResult (llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*), mlir::TranslateFromMLIRRegistration::TranslateFromMLIRRegistration(llvm::StringRef, std::function<mlir::LogicalResult (mlir::ModuleOp, llvm::raw_ostream&)> const&, std::function<void (mlir::DialectRegistry&)> const&)::'lambda'(llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*)>::_M_invoke(std::_Any_data const&, llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*&&) /usr/include/c++/7/bits/std_function.h:303:0
#19 0x00005608f045b132 std::function<mlir::LogicalResult (llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*)>::operator()(llvm::SourceMgr&, llvm::raw_ostream&, mlir::MLIRContext*) const /usr/include/c++/7/bits/std_function.h:707:0
#20 0x00005608f045816d mlir::mlirTranslateMain(int, char**, llvm::StringRef)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&)::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, llvm::raw_ostream&) const /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Translation/Translation.cpp:194:0
#21 0x00005608f04589ae mlir::mlirTranslateMain(int, char**, llvm::StringRef) /home/wmoses/git/Polygeist/llvm-project/mlir/lib/Translation/Translation.cpp:209:0
#22 0x00005608efe96310 main /home/wmoses/git/Polygeist/llvm-project/mlir/tools/mlir-translate/mlir-translate.cpp:34:0
#23 0x00007f9166056bf7 __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#24 0x00005608efe961ca _start (/home/wmoses/git/Polygeist/mlir-build/bin/mlir-translate+0x9d1ca)
Segmentation fault (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtzqzYQ_jXkRWOPuMODH5yL23SSNpOkfegLI0DY9AByJZHE_74rAeYS55wTHyftQzMeInTZ_fbb1UpIMUt3C8PDza8onkoDXxp4WbK0LigiUvI8riUVyPDPVfM8JZJEBdmxWiLDvkSGZdFZadhLOttaPoaCbemHejXHr6rkOfoxy7tCFqhBphXMqkAVvG4MtD1ANSgwrAuklUvC11RGAGoL6Fr1L4EXQd-6-lKx52pW5FX9MltXtRroXyrgjU2okVEWOZ-vCxaTAuWVpLyCguHg6M9f7cTEN6YF4p9yUkR5lcsrQyEIQdcSdJlagpC8TqRhX0BbrloN-2qoBkFPF2t4vcaEVUKSSsIYU0tTBLSCVXE41uzHkqJgCWkEvnwDgYYYtHJnuqrtv5UcOh8apX5D1VavumAk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