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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] inline pass crashed with an assertion failure.
        </td>
    </tr>

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

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

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

<pre>
    MLIR built at commit https://github.com/llvm/llvm-project/commit/6924a49690eee074f6c341d3ada4e98d640b8a7e

Reproduced with: 
`mlir-opt --inline temp.mlir`

[temp.mlir.txt](https://github.com/llvm/llvm-project/files/9915719/temp.mlir.txt)

carsh bcaktrace:
```
Assertion failed: (detail::isPresent(Val) && "dyn_cast on a non-existent value"), function dyn_cast, file Casting.h, line 648.
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 --inline temp.mlir
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  mlir-opt                 0x0000000104e2210c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 72
1  mlir-opt                 0x0000000104e22628 PrintStackTraceSignalHandler(void*) + 28
2  mlir-opt                 0x0000000104e20738 llvm::sys::RunSignalHandlers() + 148
3  mlir-opt                 0x0000000104e23ef8 SignalHandler(int) + 252
4  libsystem_platform.dylib 0x00000001a33254c4 _sigtramp + 56
5  libsystem_pthread.dylib  0x00000001a330dee0 pthread_kill + 288
6  libsystem_c.dylib        0x00000001a3248340 abort + 168
7  libsystem_c.dylib        0x00000001a3247754 err + 0
8  mlir-opt                 0x0000000104f03158 decltype(auto) llvm::dyn_cast<mlir::MemRefType, mlir::Type>(mlir::Type const&) + 96
9  mlir-opt                 0x0000000104f030e4 mlir::MemRefType mlir::Type::dyn_cast<mlir::MemRefType>() const + 24
10 mlir-opt                 0x00000001058614f8 (anonymous namespace)::EraseDeadLinalgOp::matchAndRewrite(mlir::linalg::LinalgOp, mlir::PatternRewriter&) const + 156
11 mlir-opt                 0x0000000105b5e620 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::linalg::LinalgOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const + 80
12 mlir-opt                 0x00000001096ad8e8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) + 1432
13 mlir-opt                 0x00000001089ff820 (anonymous namespace)::GreedyPatternRewriteDriver::simplify(llvm::MutableArrayRef<mlir::Region>) + 1640
14 mlir-opt                 0x00000001089ff068 mlir::applyPatternsAndFoldGreedily(llvm::MutableArrayRef<mlir::Region>, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 240
15 mlir-opt                 0x00000001054adfb4 mlir::applyPatternsAndFoldGreedily(mlir::Operation*, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) + 76
16 mlir-opt                 0x00000001088f01d0 (anonymous namespace)::Canonicalizer::runOnOperation() + 132
17 mlir-opt                 0x0000000108878838 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 512
18 mlir-opt                 0x0000000108878f08 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 364
19 mlir-opt                 0x0000000108887030 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_6::operator()(mlir::OpPassManager&, mlir::Operation*) const + 556
20 mlir-opt                 0x0000000108886df0 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_6>(long, mlir::OpPassManager&, mlir::Operation*) + 84
21 mlir-opt                 0x00000001054538f8 llvm::function_ref<mlir::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::operator()(mlir::OpPassManager&, mlir::Operation*) const + 100
22 mlir-opt                 0x000000010544c86c mlir::Pass::runPipeline(mlir::OpPassManager&, mlir::Operation*) + 52
23 mlir-opt                 0x000000010894a5e8 (anonymous namespace)::InlinerPass::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) + 360
24 mlir-opt                 0x000000010894a298 (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0::operator()(mlir::CallGraphNode*) const + 244
25 mlir-opt                 0x0000000108949fd8 mlir::LogicalResult mlir::failableParallelForEach<mlir::CallGraphNode**, (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0>(mlir::MLIRContext*, mlir::CallGraphNode**, mlir::CallGraphNode**, (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0&&) + 152
26 mlir-opt                 0x0000000108949168 mlir::LogicalResult mlir::failableParallelForEach<llvm::MutableArrayRef<mlir::CallGraphNode*>&, (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0>(mlir::MLIRContext*, llvm::MutableArrayRef<mlir::CallGraphNode*>&, (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0&&) + 84
27 mlir-opt                 0x0000000108948a58 (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*) + 392
28 mlir-opt                 0x0000000108947d84 (anonymous namespace)::InlinerPass::optimizeSCC(mlir::CallGraph&, (anonymous namespace)::CGUseList&, (anonymous namespace)::CallGraphSCC&, mlir::MLIRContext*) + 316
29 mlir-opt                 0x0000000108947b9c (anonymous namespace)::InlinerPass::inlineSCC((anonymous namespace)::Inliner&, (anonymous namespace)::CGUseList&, (anonymous namespace)::CallGraphSCC&, mlir::MLIRContext*) + 76
30 mlir-opt                 0x0000000108947b3c (anonymous namespace)::InlinerPass::runOnOperation()::$_4::operator()((anonymous namespace)::CallGraphSCC&) const + 52
31 mlir-opt                 0x0000000108947af4 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>::callback_fn<(anonymous namespace)::InlinerPass::runOnOperation()::$_4>(long, (anonymous namespace)::CallGraphSCC&) + 48
32 mlir-opt                 0x000000010894253c llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>::operator()((anonymous namespace)::CallGraphSCC&) const + 64
33 mlir-opt                 0x0000000108931888 runTransformOnCGSCCs(mlir::CallGraph const&, llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>) + 128
34 mlir-opt                 0x000000010891d538 (anonymous namespace)::InlinerPass::runOnOperation() + 328
35 mlir-opt                 0x0000000108878838 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) + 512
36 mlir-opt                 0x0000000108878f08 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) + 364
37 mlir-opt                 0x000000010887b0cc mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) + 108
38 mlir-opt                 0x000000010887aea0 mlir::PassManager::run(mlir::Operation*) + 732
39 mlir-opt                 0x000000010885fb80 performActions(llvm::raw_ostream&, bool, bool, llvm::SourceMgr&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) + 560
40 mlir-opt                 0x000000010885f714 processBuffer(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) + 496
41 mlir-opt                 0x000000010885f4dc mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 204
42 mlir-opt                 0x000000010885f3f0 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) + 80
43 mlir-opt                 0x0000000108a5c700 llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const + 96
44 mlir-opt                 0x0000000108a5c1e4 mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) + 128
45 mlir-opt                 0x000000010885ce48 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) + 320
46 mlir-opt                 0x000000010885d050 mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) + 296
47 mlir-opt                 0x000000010885dbfc mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) + 2888
48 mlir-opt                 0x0000000104661df8 main + 148
49 dyld                     0x00000001217c1088 start + 516
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztW1tT4zoS_jXhRQXli3x74CEEZg5VZEkBe6p2X1KKJSfe49heSWYm59dvS77EToAowJwDs0OliCNLffm61eqW7EVBN-fTm-s7tKjSTCIiUVys16lEKylLMXLHI-cLfJapXFWLM7gHP7Lssf06LXnxHxZL-FmPgws_cjDBkR9ZjDErwIkfu9imLqEEsyikPrYWIQnYyLocWeP6_x0DQrSKGUXfgBXwRc1t31pnKT8tSolOT9M8S3OGJFuXZ6oZ7vapjLyL7taZ_C5H3uXICY_WJEkzJuA7imwvsCO4GlJ1oj7TmHCxQouY_CE5iZli1ErefPTPsRCMy7TIUUKAPtUqOiFlEn6qQe44FTPOBMuBQ_g7yYAP9PDhA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