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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] -ensure-debug-info-scope-on-llvm-func crashes 
        </td>
    </tr>

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

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

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

<pre>
    git version: 8168088f0a9015b

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -ensure-debug-info-scope-on-llvm-func a.mlir`


a.mlir:
``` 
module {
  func.func @test(%arg0: memref<3x2xi8>) -> memref<2x3xi8> {
    %0 = bufferization.to_tensor %arg0 : memref<3x2xi8>
    %1 = tosa.reshape %0 {new_shape = array<i64: 2, 3>} : (tensor<3x2xi8>) -> tensor<2x3xi8>
    %2 = bufferization.to_memref %1 : memref<2x3xi8>
    return %2 : memref<2x3xi8>
  }
}
``` 
stack trace:

``` 
LLVM ERROR: can't create Attribute 'mlir::LLVM::DIFileAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, or the attribute wasn't added with addAttributes<...>() in the Dialect::initialize() method.
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 -ensure-debug-info-scope-on-llvm-func a.mlir
 #0 0x00005595184772c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10dc2c8)
 #1 0x0000559518474dde llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d9dde)
 #2 0x0000559518477c5d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007effd1388420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007effd09c500b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007effd09a4859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x0000559518496f67 llvm::report_fatal_error(llvm::Twine const&, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10fbf67)
 #7 0x00005595196254fa (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x228a4fa)
 #8 0x00005595195fb041 mlir::LLVM::DIFileAttr::get(mlir::MLIRContext*, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x2260041)
 #9 0x00005595195d138e (anonymous namespace)::DIScopeForLLVMFuncOp::runOnOperation() DIScopeForLLVMFuncOp.cpp:0:0
#10 0x000055951b59e156 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203156)
#11 0x000055951b59eac0 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+0x4203ac0)
#12 0x000055951b5a1102 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4206102)
#13 0x000055951b599931 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#14 0x000055951b59958b 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
#15 0x000055951b645f25 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+0x42aaf25)
#16 0x000055951b5949b5 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+0x41f99b5)
#17 0x000055951b594c5f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9c5f)
#18 0x000055951b594f8e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9f8e)
#19 0x0000559518457f07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bcf07)
#20 0x00007effd09a6083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#21 0x0000559518457a8e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bca8e)
``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWV1v47oR_TXMC2GBor4f_OBNYnSBBAmSbV8NShzJ7MqkSlIbe399QUr-kNfJ7r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