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

    <tr>
        <th>Summary</th>
        <td>
            MLIR assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"` failed
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          alex-s168
      </td>
    </tr>
</table>

<pre>
    [Input file (not minimal at all)](http://207.180.202.42/ezpaste/view.php?file=V50o3e756eAwCd2.txt&key=)
```
mlir-opt: /home/alex/llvm-project/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From*) [with To = mlir::SymbolOpInterface; >From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' 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 .in.mlir -o .out.mlir --ownership-based-buffer-deallocation -convert-bufferization-to-memref --convert-tensor-to-linalg --convert-linalg-to-affine-loops --lower-affine -convert-scf-to-cf --convert-to-llvm --reconcile-unrealized-casts
 #0 0x0000756270f880ae llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/../lib/libLLVM.so.18.1+0x45880ae)
 #1 0x0000756270f8510b llvm::sys::RunSignalHandlers() (/usr/bin/../lib/libLLVM.so.18.1+0x458510b)
 #2 0x0000756270f85245 SignalHandler(int) Signals.cpp:0:0
 #3 0x000075626c45a770 (/usr/bin/../lib/libc.so.6+0x3c770)
 #4 0x000075626c4ab32c (/usr/bin/../lib/libc.so.6+0x8d32c)
 #5 0x000075626c45a6c8 raise (/usr/bin/../lib/libc.so.6+0x3c6c8)
 #6 0x000075626c4424b8 abort (/usr/bin/../lib/libc.so.6+0x244b8)
 #7 0x000075626c4423dc (/usr/bin/../lib/libc.so.6+0x243dc)
 #8 0x000075626c452d46 (/usr/bin/../lib/libc.so.6+0x34d46)
 #9 0x00005631277f97cd (anonymous namespace)::BufferDeallocation::deallocate(mlir::Block*) OwnershipBasedBufferDeallocation.cpp:0:0
#10 0x00005631277fa42c mlir::WalkResult llvm::function_ref<mlir::WalkResult (mlir::Block*)>::callback_fn<(anonymous namespace)::BufferDeallocation::deallocate(mlir::FunctionOpInterface)::'lambda'(mlir::Block*)>(long, mlir::Block*) OwnershipBasedBufferDeallocation.cpp:0:0
#11 0x00005631277fb21d mlir::WalkResult mlir::detail::walk<mlir::ForwardDominanceIterator<false>>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Block*)>, mlir::WalkOrder) (/usr/bin/mlir-opt+0x292221d)
#12 0x00005631277fb528 mlir::bufferization::deallocateBuffersOwnershipBased(mlir::FunctionOpInterface, bool) (/usr/bin/mlir-opt+0x2922528)
#13 0x00005631277fc124 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) OwnershipBasedBufferDeallocation.cpp:0:0
#14 0x00005631277fc094 mlir::WalkResult mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<mlir::WalkResult (mlir::Operation*)>, mlir::WalkOrder) (.constprop.0) OwnershipBasedBufferDeallocation.cpp:0:0
#15 0x00005631277fc259 (anonymous namespace)::OwnershipBasedBufferDeallocationPass::runOnOperation() OwnershipBasedBufferDeallocation.cpp:0:0
#16 0x0000563129f66b1e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/usr/bin/mlir-opt+0x508db1e)
#17 0x0000563129f67148 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/usr/bin/mlir-opt+0x508e148)
#18 0x0000563129f680dd mlir::PassManager::run(mlir::Operation*) (/usr/bin/mlir-opt+0x508f0dd)
#19 0x0000563129f4b9c9 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x0000563129f4cb33 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#21 0x0000563129f4cc88 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&) MlirOptMain.cpp:0:0
#22 0x000056312a065523 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) (/usr/bin/mlir-opt+0x518c523)
#23 0x0000563129f45b6e mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/usr/bin/mlir-opt+0x506cb6e)
#24 0x0000563129f4cdcd mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/usr/bin/mlir-opt+0x5073dcd)
#25 0x0000563129f4d27b mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/usr/bin/mlir-opt+0x507427b)
#26 0x0000563127325eb3 main (/usr/bin/mlir-opt+0x244ceb3)
#27 0x000075626c443cd0 (/usr/bin/../lib/libc.so.6+0x25cd0)
#28 0x000075626c443d8a __libc_start_main (/usr/bin/../lib/libc.so.6+0x25d8a)
#29 0x0000563127317fb5 _start (/usr/bin/mlir-opt+0x243efb5)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWVtv2zrW_TXMC2GBInXzQx6cpMYXoEGCpuj3GFDkls0JRWpIqkn66weU7dhS7p2cmc5gDk6LiqQW1177wk2Le69WBuAY5ScoPzvifVhbd8w13M98WlRHtZUPcfLcdH3AjdKAEa2MDbhVRrVcYx4w1xrROcrPEK3WIXSILRBdIrqkpEzSiiSU0CSjiC7hV8d9AESXPxXcJd26Q2wZURE7-5ETy6DMC1jcnUqahPuAaHELD4idRXhyhsgCFWT7__DYauVmtguILTCiy7VtI3akj-hS65_trHP2byDC9hHRpTJC9xL2A9d911kXV5xyH5RZJWvEFkVBI6gEocNDB4hWvA8W0TkeXmMLxBbywdwI7gOi1dLZFtFFnEf5yZ0Ka_zdYsTOcKS4WX790NZWX3bnJoBruADETnB8cbLusgPHg7ImKsoWeOE9uPiMUUEkBK70ZqHyVw48mEjgB9fD5rRAtMCI0h05bA3m2Fgzg3vlA5iAf3LdA6IU0RI3XGmQyUbOq69fFtdfsO_rVgXMcd2vsIOoDg4WR9f6R9-uVFj3dSKi3TspJ4or73vwiC4xNxJvhcdhDVg47te45uI2OC5gu_114OIWy74dImgYIgke_rtyduV4i7lb9S2YEHngnfdxokwSH_DM4sT2Yfsws3cGnF-rblZzD3JW900DbiaBa23FoDGeCWt-ggvbSfVrGJ4FO2uhddDg2eOKAMZbF6e0MlyvDqY2A3GKN40yMNPWdh7PZtregdsO7vf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