Issue 203859
Summary [mlir]Assertion `hasSingleElement(C) && "expected container with single element"' failed.
Labels mlir
Assignees
Reporter Anonymous7i0em3yd
    git version: 58031e519153fdbe637f9f135ac1fbfef6f0e224

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt -convert-nvgpu-to-nvvm -test-legalize-type-conversion a.mlir`

a.mlir:  

```mlir
module {
 func.func @fuse_2nd_for_into_1st(%arg0: memref<?x?xi32>, %arg1: index, %arg2: index, %arg3: index) {
    %c0 = arith.constant 0 : index
    %c0_0 = arith.constant 0 : index
    %c10 = arith.constant 10 : index
    %c1 = arith.constant 1 : index
    %0 = scf.for %arg4 = %c0_0 to %c10 step %c1 iter_args(%arg5 = %arg0) -> (memref<?x?xi32>) {
      %c0_1 = arith.constant 0 : index
      %c0_2 = arith.constant 0 : index
      %1 = scf.for %arg6 = %c0_1 to %arg2 step %c1 iter_args(%arg7 = %arg5) -> (memref<?x?xi32>) {
 %c0_3 = arith.constant 0 : index
        %c0_4 = arith.constant 0 : index
        %c10_5 = arith.constant 10 : index
        %c1_6 = arith.constant 1 : index
        %2 = scf.for %arg8 = %c0_3 to %c10_5 step %c1 iter_args(%arg9 = %arg7) -> (memref<?x?xi32>) {
          %3 = memref.load %arg9[%arg1, %c0_4] : memref<?x?xi32>
          memref.store %3, %arg9[%arg1, %c0_4] : memref<?x?xi32>
          scf.yield %arg9 : memref<?x?xi32>
        }
        scf.yield %2 : memref<?x?xi32>
      }
 scf.yield %1 : memref<?x?xi32>
    }
    test.copy(%0, %arg0) : (memref<?x?xi32>, memref<?x?xi32>)
    return
  }
}

```

stack trace:

```
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/ADT/STLExtras.h:309: decltype(auto) llvm::getSingleElement(ContainerTy &&) [ContainerTy = const mlir::ValueRange]: Assertion `hasSingleElement(C) && "expected container with single element"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-nvgpu-to-nvvm -test-legalize-type-conversion 14.mlir
 #0 0x00005623734bf798 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1ff4798)
 #1 0x00005623734bc631 llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1ff1631)
 #2 0x00005623734c08b6 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f30a4ae7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f30a412400b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f30a4103859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f30a4103729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f30a4103729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f30a4114fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x0000562379d54be1 (anonymous namespace)::Structural1ToNConversionPattern<mlir::scf::ForOp, (anonymous namespace)::ConvertForOpTypes>::matchAndRewrite(mlir::scf::ForOp, mlir::scf::ForOpGenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) const StructuralTypeConversions.cpp:0:0
#10 0x00005623753b789a mlir::OpConversionPattern<mlir::scf::ForOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3eec89a)
#11 0x000056237bdd21b4 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9071b4)
#12 0x000056237be2027d void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_0>(long) PatternApplicator.cpp:0:0
#13 0x000056237be1cbda mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa951bda)
#14 0x000056237bdd3f5a (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#15 0x000056237bdd371c mlir::OperationConverter::convert(mlir::Operation*, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa90871c)
#16 0x000056237bdd4a80 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa909a80)
#17 0x000056237bde2d69 void llvm::function_ref<void ()>::callback_fn<applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode)::$_0>(long) DialectConversion.cpp:0:0
#18 0x000056237bdd9e97 applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#19 0x000056237bdd9f7b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa90ef7b)
#20 0x000056237368f9c7 (anonymous namespace)::TestTypeConversionDriver::runOnOperation() TestPatterns.cpp:0:0
#21 0x000056237be7bc22 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9b0c22)
#22 0x000056237be7ca64 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+0xa9b1a64)
#23 0x000056237be8397a mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9b897a)
#24 0x000056237be832af mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xa9b82af)
#25 0x0000562373570940 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x000056237356fb76 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::MemoryBufferRef const&, 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::MemoryBufferRef const&, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#27 0x000056237c1d0ca5 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::MemoryBufferRef const&, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0xad05ca5)
#28 0x0000562373565776 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+0x209a776)
#29 0x0000562373565b55 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x209ab55)
#30 0x0000562373565eb5 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x209aeb5)
#31 0x00005623734a5222 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1fda222)
#32 0x00007f30a4105083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x00005623734a4d5e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1fd9d5e)
Aborted (core dumped)
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to