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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Inline pass crashed with assertion failure "(succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...)))"
        </td>
    </tr>

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

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

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

<pre>
    MLIR built at commit  585cbe3f
Reproduced with:  
` mlir-opt -inline temp.mlir`

This is an issue similar to [issue](https://github.com/llvm/llvm-project/issues/61056), where `tensor.empty` is initialized with a negative index `%133`.
 temp.mlir:
``` milr 
module {
  func.func @func1()  {
    %true_0 = arith.constant true
    %cst = arith.constant 6.483200e+04 : f16
 %true_2 = arith.constant true
    %c7 = arith.constant 7 : index
 %c12 = arith.constant 12 : index
    %c20 = arith.constant 20 : index
 %c28 = arith.constant 28 : index
    %38 = memref.alloca_scope  -> (tensor<?x?xf32>) {
      %133 = index.sub %c12, %c20
      %158 = tensor.empty(%c28, %133) : tensor<?x?xf32> // !!!!!!!!!!!
 memref.alloca_scope.return %158 : tensor<?x?xf32>
    }
    %91 = scf.index_switch %c7 -> vector<28x28xf16> 
    default {
      %146 = math.tanh %38 : tensor<?x?xf32>
      %149 = vector.broadcast %cst : f16 to vector<28x28xf16>
      scf.yield %149 : vector<28x28xf16>
    } 
    return 
  }
}

```
 
trace:
```console
<unknown>:0: error: invalid tensor dimension size
Assertion failed: (succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))), function get, file StorageUniquerSupport.h, line 180.
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
 #0 0x0000000100d10f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8f18)
 #1 0x0000000100d0f1b4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f71b4)
 #2 0x0000000100d115c4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f95c4)
 #3 0x00000001be7894c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
 #4 0x00000001be771ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
 #5 0x00000001be6ac340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
 #6 0x00000001be6ab754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
 #7 0x00000001052f8348 mlir::detail::skipDefaultMemorySpace(mlir::Attribute) (.cold.1) (/workspace/build/bin/mlir-opt+0x1048e0348)
 #8 0x0000000103452b04 mlir::RankedTensorType mlir::detail::StorageUserBase<mlir::RankedTensorType, mlir::TensorType, mlir::detail::RankedTensorTypeStorage, mlir::detail::TypeUniquer, mlir::ShapedType::Trait>::get<llvm::ArrayRef<long long>, mlir::Type, mlir::Attribute>(mlir::MLIRContext*, llvm::ArrayRef<long long>, mlir::Type, mlir::Attribute) (/workspace/build/bin/mlir-opt+0x102a3ab04)
 #9 0x00000001034529f0 mlir::RankedTensorType::get(llvm::ArrayRef<long long>, mlir::Type, mlir::Attribute) (/workspace/build/bin/mlir-opt+0x102a3a9f0)
#10 0x00000001027ad458 (anonymous namespace)::ReplaceEmptyTensorStaticShapeDims::matchAndRewrite(mlir::tensor::EmptyOp, mlir::PatternRewriter&) const (/workspace/build/bin/mlir-opt+0x101d95458)
#11 0x00000001049930f0 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&)>)::$_2::operator()() const (/workspace/build/bin/mlir-opt+0x103f7b0f0)
#12 0x00000001049903ec 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&)>) (/workspace/build/bin/mlir-opt+0x103f783ec)
#13 0x00000001033bf420 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() (/workspace/build/bin/mlir-opt+0x1029a7420)
#14 0x00000001033bcc50 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/workspace/build/bin/mlir-opt+0x1029a4c50)
#15 0x0000000103376c5c (anonymous namespace)::Canonicalizer::runOnOperation() (/workspace/build/bin/mlir-opt+0x10295ec5c)
#16 0x00000001033602a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#17 0x0000000103360998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#18 0x0000000103386418 (anonymous namespace)::InlinerPass::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0::operator()(mlir::CallGraphNode*) const (/workspace/build/bin/mlir-opt+0x10296e418)
#19 0x0000000103385f3c (anonymous namespace)::InlinerPass::inlineSCC((anonymous namespace)::Inliner&, (anonymous namespace)::CGUseList&, (anonymous namespace)::CallGraphSCC&, mlir::MLIRContext*) (/workspace/build/bin/mlir-opt+0x10296df3c)
#20 0x000000010337e1cc (anonymous namespace)::InlinerPass::runOnOperation() (/workspace/build/bin/mlir-opt+0x1029661cc)
#21 0x00000001033602a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#22 0x0000000103360998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#23 0x000000010336282c mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x10294a82c)
#24 0x000000010335ad14 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102942d14)
#25 0x000000010335a368 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>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102942368)
#26 0x00000001033d834c 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) (/workspace/build/bin/mlir-opt+0x1029c034c)
#27 0x0000000103354d1c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10293cd1c)
#28 0x000000010335518c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x10293d18c)
#29 0x0000000100a1b510 main (/workspace/build/bin/mlir-opt+0x100003510)
#30 0x000000010c1d1088 

``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1y27iSfhr4BhUVCJAUeeELRbZnU5VsXHam9tIFgk0JaxLkAqBt5em3AFKWQFn-0WTOnJozKUeUwEb_fuhugOTGyJUCOEfJZ5RcnPHerlt9vmzruu1abXtDzoq23Jx_-_rlBhe9rC3mFou2aaTFOMkSUQCrELlAZHEDnW7LXkCJH6VdI7bAeLiDUoKbWupPbWfxJ6lqqQBbaLqZG0UpGcn854-1NFgazBWWxvSAjWxkzTW2LUbJZz-GkgtEs7W1nUFsgegVolcradd9MRNtg-hVXT9sL5863f4vCIvolZ9rEL1KI5KkiOaILvHjGjRglBILyrR6Bk1nN05jp4aSVvJa_hxtwhwrWHErHwBLVcKTm4doEjGGUjIbDNizjC2eHTD84UbWevRK05Z9DRjNP4_zcNUrMXMfGMXEXSNEM0RzvE-EMaKJ1T3cEYzYBeZa2vVMtMpYrix2dwJSYexLdOkszhglBBD9TGLsolVF6ThzK4G-T8L8JbK55-m9tOMqohdZ-tGQeGRNXzTSjx4yp9mLxNkR5mwgb6DRUM14XbeC3xnRdoDxJ8QuMaLZAArElohdPbn_FaOIXbqgBDHxDCPGPEcvamb6YjTZwWwwZjohGVQIoOdC7mwZZzlsOWlsgY8og4cFgBGN3vgbpL9g8EyD7bXa6XRU2J4H5xeBO_PI22JENfMOuDOP0or1iBDv0AcQ1vOk2RPNnhzgnPrPXEqoeF_bl1wbp0OwuF3PLFfr5wC-Q9ORQ-45DDrMCt3yUnC3OLZrxK8Al2ZeVHOfnbNxI6Eud4wXb81C84s9S7f-Hgeefbn7EiaOLcr9xWou4DC5OMS39bg2EVv26l61j8ppwRbEqQhaOw3dYnjgtSxH1-FSNqCMbBU28ufIYGEMaOvGKi5rKN00RDPTCwFQQolotmy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