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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] -convert-ub-to-spirv crashes
        </td>
    </tr>

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

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

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

<pre>
    git version: adf892d743d91afc1af7893f97c770db31c26916

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt  -convert-ub-to-spirv  a.mlir`


a.mlir: 
``` 
func.func @test_subi(%A : tensor<?x32xi32>, %B : tensor<?x32xi32>, %C : tensor<?x?xi32>) {
  %0 = arith.subi %A, %B : tensor<?x32xi32>
  %1 = arith.subi %C, %C : tensor<?x?xi32>
  return
}

``` 
stack trace:

``` 
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1346: static DenseElementsAttr mlir::DenseIntOrFPElementsAttr::getRaw(ShapedType, ArrayRef<char>): Assertion `type.hasStaticShape() && "type must have static shape"' failed.
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 -convert-ub-to-spirv /data/szy/MLIR/seed726/tmp.Wn2nlKqwzv.mlir
 #0 0x00005615b4c9c048 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1188048)
 #1 0x00005615b4c99b5e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1185b5e)
 #2 0x00005615b4c9c9dd SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f301691b420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f3015f5800b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f3015f37859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f3015f37729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f3015f37729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f3015f48fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x00005615b81cb46a mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x46b746a)
#10 0x00005615b81ca276 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x46b6276)
#11 0x00005615b81bd659 mlir::Builder::getZeroAttr(mlir::Type) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x46a9659)
#12 0x00005615b4e9c678 mlir::arith::SubIOp::fold(mlir::arith::SubIOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1388678)
#13 0x00005615b4f884ae llvm::LogicalResult mlir::Op<mlir::arith::SubIOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::Type>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::NOperands<2u>::Impl, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferIntRangeInterface::Trait, mlir::arith::ArithIntegerOverflowFlagsInterface::Trait, mlir::OpTrait::SameOperandsAndResultType, mlir::VectorUnrollOpInterface::Trait, mlir::OpTrait::Elementwise, mlir::OpTrait::Scalarizable, mlir::OpTrait::Vectorizable, mlir::OpTrait::Tensorizable, mlir::InferTypeOpInterface::Trait>::foldSingleResultHook<mlir::arith::SubIOp>(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x14744ae)
#14 0x00005615b4f86840 mlir::RegisteredOperationName::Model<mlir::arith::SubIOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1472840)
#15 0x00005615b827dd2d mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4769d2d)
#16 0x00005615b827e0d3 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x476a0d3)
#17 0x00005615b81be45a mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x46aa45a)
#18 0x00005615b813845c (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#19 0x00005615b8137827 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4623827)
#20 0x00005615b81389ff mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x46249ff)
#21 0x00005615b813ebbb mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x462abbb)
#22 0x00005615b7ace65a (anonymous namespace)::UBToSPIRVConversionPass::runOnOperation() UBToSPIRV.cpp:0:0
#23 0x00005615b80d87a6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45c47a6)
#24 0x00005615b80d90d0 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+0x45c50d0)
#25 0x00005615b80db6a2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45c76a2)
#26 0x00005615b80d3f4a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x00005615b80d3b9d 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
#28 0x00005615b817fd75 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+0x466bd75)
#29 0x00005615b80cdb85 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+0x45b9b85)
#30 0x00005615b80cde2f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45b9e2f)
#31 0x00005615b80ce15e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x45ba15e)
#32 0x00005615b4c7cb37 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1168b37)
#33 0x00007f3015f39083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#34 0x00005615b4c7c6ae _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11686ae)
``` 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWltT67iy_jXmRUVKlu8PPIRAzlBnMVCEmVN1XlKyJDvaS5E9kgxk_fpdkp34QrjNnszsmVULiOOWur-vW61u2VhrXkrGLrzo0ouuznBjNpW6eH7exX7mn-UV3V2U3IAnpjSvpBfMAaZFmiGahAHNfFwQHxdJmgVFlpAkgTQPfILizI89OPfgXO-0YVs7zovhL3kjTQP8dAbDWQy-Pa68GLZyitWqog1h4JmbTSe_FVydV7UB4JxU8okpc97k56Y61zVXTwDgmZU4zOHBefeNHQ7n9ob7by-KRpKZ_QW8EBqmzVo3OfdQ6qFoDuwIw6SulBcsvGD5EqAXHiAvuPbQAngouvxYZPFax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