llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.02k stars 11.57k forks source link

[MLIR]`test-extract-fixed-outer-loops` pass with no option leads to Assertion Failure '!empty()' #61716

Open BealZephyr opened 1 year ago

BealZephyr commented 1 year ago

I think a default value of test-outer-loop-sizes should be set to avoid this crash.

Test commit: https://github.com/llvm/llvm-project/commit/938deaad8ac92d9a45db8ef2d8a71fbf04958d90

steps to reproduce:

mlir-opt test.mlir -test-extract-fixed-outer-loops

test case:

  func.func @main(%arg0: memref<?x?xf32>) {
    %c2 = arith.constant 2 : index
    %c44 = arith.constant 44 : index
    %c1 = arith.constant 1 : index
    scf.for %arg1 = %c2 to %c44 step %c1 {
      scf.for %arg2 = %c1 to %c44 step %c2 {
        %0 = memref.load %arg0[%arg1, %arg2] : memref<?x?xf32>
      }
    }
    return
  }

crash trace:

mlir-opt: /home/ty/llvm-project/llvm/include/llvm/ADT/SmallVector.h:312: T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::back() [with T = mlir::scf::ForOp; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::reference = mlir::scf::ForOp&]: Assertion `!empty()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /home/ty/llvm-project/build/bin/mlir-opt test.mlir -test-extract-fixed-outer-loops
 #0 0x0000563a9a8452fa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ty/llvm-project/build/bin/mlir-opt+0x2282fa)
 #1 0x0000563a9a84258c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fe71745d980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #3 0x00007fe71610ee87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #4 0x00007fe7161107f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #5 0x00007fe7161003fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #6 0x00007fe716100472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #7 0x0000563a9b3dc817 mlir::extractFixedOuterLoops(mlir::scf::ForOp, llvm::ArrayRef<long>) (/home/ty/llvm-project/build/bin/mlir-opt+0xdbf817)
 #8 0x0000563a9bdba764 _ZN4llvm12function_refIFvPN4mlir9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_130SimpleParametricLoopTilingPass14runOnOperationEvEUlNS1_3scf5ForOpEE_SE_vEENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S3_ESI_ISJ_PNS1_6RegionEESI_ISJ_PNS1_5BlockEEEE5valuesrSI_IT3_vE5valueESS_E4typeES3_OT1_EUlS3_E_EEvlS3_ TestLoopParametricTiling.cpp:0:0
 #9 0x0000563a9bdba549 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.191) TestLoopParametricTiling.cpp:0:0
#10 0x0000563a9bdba8e5 (anonymous namespace)::SimpleParametricLoopTilingPass::runOnOperation() TestLoopParametricTiling.cpp:0:0
#11 0x0000563a9c13e08e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b2108e)
#12 0x0000563a9c13eee3 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.510) Pass.cpp:0:0
#13 0x0000563a9c13f56d mlir::PassManager::run(mlir::Operation*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b2256d)
#14 0x0000563a9c1334e3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#15 0x0000563a9c133bb1 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
#16 0x0000563a9c133da1 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
#17 0x0000563a9c2006f0 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) (/home/ty/llvm-project/build/bin/mlir-opt+0x1be36f0)
#18 0x0000563a9c12eec3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b11ec3)
#19 0x0000563a9c1316ee mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b146ee)
#20 0x0000563a9a8112f0 main (/home/ty/llvm-project/build/bin/mlir-opt+0x1f42f0)
#21 0x00007fe7160f1c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#22 0x0000563a9a82414a _start (/home/ty/llvm-project/build/bin/mlir-opt+0x20714a)
llvmbot commented 1 year ago

@llvm/issue-subscribers-mlir