Issue 71153
Summary [mlir] --inline crashed with assertion failure "succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))"
Labels mlir
Assignees
Reporter anonymousMCS
    git version: a1358225c5b791fa9d901e74fb09606189c0e6af

system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```

reproduced with: ```mlir-opt --inline a.mlir```

a.mlir:
```
func.func nested @func1() {
  %c0 = arith.constant 0 : index
  %c2 = arith.constant 2 : index
  %c3 = arith.constant 3 : index
  %c10 = arith.constant 10 : index
  %c11 = arith.constant 11 : index
  %c12 = arith.constant 12 : index
  %c13 = arith.constant 13 : index
  %c15 = arith.constant 15 : index
  %c16 = arith.constant 16 : index
  %c29 = arith.constant 29 : index
  %alloc_8 = memref.alloc() {alignment = 64 : i64} : memref<11x9xi32>
  %alloc_18 = memref.alloc(%c10) {alignment = 64 : i64} : memref<?x1xi1>
  %17 = index.shl %c10, %c11
  %20 = index.and %c15, %c2
  %22 = index.add %17, %17
  %expand_shape = memref.expand_shape %alloc_18 [[0], [1, 2]] : memref<?x1xi1> into memref<?x1x1xi1>
  %27 = bufferization.to_tensor %expand_shape : memref<?x1x1xi1>
  %c128 = arith.constant 128 : index
 %36 = arith.remsi %22, %c128 : index
  %37 = arith.cmpi slt, %36, %c0 : index
  %38 = arith.addi %36, %c128 : index
  %39 = arith.select %37, %38, %36 : index
  %c128_51 = arith.constant 128 : index
  %c1_53 = arith.constant 1 : index
  %40 = arith.cmpi sle, %39, %c0 : index
  %42 = arith.subi %c3, %c1_53 : index
  %43 = arith.select %40, %c29, %c10 : index
  %44 = arith.divsi %43, %c128_51 : index
  %45 = arith.subi %c0, %20 : index
  %46 = arith.addi %44, %c1_53 : index
  %47 = arith.select %40, %45, %c1_53 : index
  %c-1 = arith.constant -1 : index
  %48 = arith.cmpi slt, %47, %c0 : index
  %49 = arith.subi %c-1, %c29 : index
 %50 = arith.select %48, %49, %47 : index
  %51 = arith.divsi %50, %22 : index
  %c-13 = arith.constant -13 : index
  %52 = arith.select %48, %c-13, %51 : index
  %54 = bufferization.to_tensor %expand_shape : memref<?x1x1xi1>
  %55 = tosa.logical_or %27, %54 : (tensor<?x1x1xi1>, tensor<?x1x1xi1>) -> tensor<?x1x1xi1>
 vector.warp_execute_on_lane_0(%c0)[32] {
    memref.alloca_scope  {
 %alloc_131 = memref.alloc(%20) {alignment = 64 : i64} : memref<?x1x1xi1>
      %164 = bufferization.to_tensor %alloc_131 : memref<?x1x1xi1>
      %165 = tosa.logical_xor %55, %164 : (tensor<?x1x1xi1>, tensor<?x1x1xi1>) -> tensor<?x1x1xi1>
      %166 = bufferization.to_memref %165 : memref<?x1x1xi1>
      %c1_137 = arith.constant 1 : index
      %179 = index.xor %c16, %c13
 %alloc_160 = memref.alloc(%52) {alignment = 64 : i64} : memref<?x1x1xi1>
 %c0_161 = arith.constant 0 : index
      %dim_162 = memref.dim %alloc_160, %c0_161 : memref<?x1x1xi1>
      %c1_166 = arith.constant 1 : index
      %c0_167 = arith.constant 0 : index
      %c1_168 = arith.constant 1 : index
      %190 = scf.for %arg0 = %c0_167 to %dim_162 step %c1_168 iter_args(%arg1 = %expand_shape) -> (memref<?x1x1xi1>) {
 %192 = scf.for %arg2 = %17 to %39 step %46 iter_args(%arg3 = %arg1) -> (memref<?x1x1xi1>) {
          %193 = memref.load %alloc_8[%c12, %arg2] : memref<11x9xi32>
          %194 = arith.index_cast %193 : i32 to index
 %subview = memref.subview %alloc_160[%c1_137, %arg2, %c0_167] [%179, %52, %c1_166] [%c1_168, %194, %22] : memref<?x1x1xi1> to memref<?x?x?xi1, strided<[?, ?, ?], offset: ?>>
          %c0_169 = arith.constant 0 : index
          %dim_170 = memref.dim %166, %c0_169 : memref<?x1x1xi1>
 %alloc_171 = memref.alloc(%dim_170) {alignment = 64 : i64} : memref<?x1x1xi1>
          %subview_172 = memref.subview %alloc_171[%arg0, %194, %39] [%c1_168, %52, %c1_168] [%42, %c1_168, %46] : memref<?x1x1xi1> to memref<?x?x?xi1, strided<[?, ?, ?], offset: ?>>
          memref.copy %subview, %subview_172 : memref<?x?x?xi1, strided<[?, ?, ?], offset: ?>> to memref<?x?x?xi1, strided<[?, ?, ?], offset: ?>>
          scf.yield %alloc_131 : memref<?x1x1xi1>
        }
        scf.yield %192 : memref<?x1x1xi1>
      }
    }
  }
  return 
}
```


trace:
```
mlir-opt: /data/bin/llvm-project/mlir/include/mlir/IR/StorageUniquerSupport.h:180: static ConcreteT mlir::detail::StorageUserBase<ConcreteT, BaseT, StorageT, UniquerT, Traits>::get(mlir::MLIRContext*, Args&& ...) [with Args = {llvm::ArrayRef<long int>&, mlir::Type&, mlir::MemRefLayoutAttrInterface&, mlir::Attribute&}; ConcreteT = mlir::MemRefType; BaseT = mlir::BaseMemRefType; StorageT = mlir::detail::MemRefTypeStorage; UniquerT = mlir::detail::TypeUniquer; Traits = {mlir::ShapedType::Trait}]: Assertion `succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))' 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/bin/llvm-project/build/bin/mlir-opt --inline a.mlir
 #0 0x0000557fb378f8bf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x15db8bf)
 #1 0x0000557fb378c954 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f87c99e5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f87c94d000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f87c94af859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f87c94af729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f87c94c0fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000557fb64aa81d mlir::MemRefType::get(llvm::ArrayRef<long>, mlir::Type, mlir::MemRefLayoutAttrInterface, mlir::Attribute) (/data/bin/llvm-project/build/bin/mlir-opt+0x42f681d)
 #8 0x0000557fb49c4fe6 mlir::memref::SubViewOp::inferResultType(mlir::MemRefType, llvm::ArrayRef<long>, llvm::ArrayRef<long>, llvm::ArrayRef<long>) (/data/bin/llvm-project/build/bin/mlir-opt+0x2810fe6)
 #9 0x0000557fb49c52a2 mlir::memref::SubViewOp::inferResultType(mlir::MemRefType, llvm::ArrayRef<mlir::OpFoldResult>, llvm::ArrayRef<mlir::OpFoldResult>, llvm::ArrayRef<mlir::OpFoldResult>) (/data/bin/llvm-project/build/bin/mlir-opt+0x28112a2)
#10 0x0000557fb49d5c3d mlir::OpWithOffsetSizesAndStridesConstantArgumentFolder<mlir::memref::SubViewOp, SubViewReturnTypeCanonicalizer, SubViewCanonicalizer>::matchAndRewrite(mlir::memref::SubViewOp, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x2821c3d)
#11 0x0000557fb9015688 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&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6e61688)
#12 0x0000557fb63c063c (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#13 0x0000557fb63c4aab mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x4210aab)
#14 0x0000557fb632a17a (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#15 0x0000557fb630b0ce mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x41570ce)
#16 0x0000557fb630b5aa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41575aa)
#17 0x0000557fb630c673 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)::'lambda'(mlir::OpPassManager&, mlir::Operation*)>(long, mlir::OpPassManager&, mlir::Operation*) Pass.cpp:0:0
#18 0x0000557fb633a363 (anonymous namespace)::InlinerPass::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) Inliner.cpp:0:0
#19 0x0000557fb6342ce5 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult ((anonymous namespace)::CallGraphSCC&)>::callback_fn<(anonymous namespace)::InlinerPass::runOnOperation()::'lambda'((anonymous namespace)::CallGraphSCC&)>(long, (anonymous namespace)::CallGraphSCC&) Inliner.cpp:0:0
#20 0x0000557fb6343ff3 (anonymous namespace)::InlinerPass::runOnOperation() Inliner.cpp:0:0
#21 0x0000557fb630b0ce mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x41570ce)
#22 0x0000557fb630b5aa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41575aa)
#23 0x0000557fb630bdd4 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x4157dd4)
#24 0x0000557fb62fcb5b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#25 0x0000557fb62fe014 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
#26 0x0000557fb62fe1c4 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
#27 0x0000557fb63fd124 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) (/data/bin/llvm-project/build/bin/mlir-opt+0x4249124)
#28 0x0000557fb62f6c77 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4142c77)
#29 0x0000557fb62fe311 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x414a311)
#30 0x0000557fb62fe776 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x414a776)
#31 0x0000557fb36c6e3b main (/data/bin/llvm-project/build/bin/mlir-opt+0x1512e3b)
#32 0x00007f87c94b1083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#33 0x0000557fb375ff8e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x15abf8e)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to