Issue 129416
Summary [mlir] Crash when using --loop-invariant-subset-hoisting
Labels mlir
Assignees
Reporter wangyongj1a
    I have the following MLIR program:
test.mlir:
```
module {
  func.func @func1() {
    %idx1 = index.constant 1
    %idx0 = index.constant 0
 %alloc = memref.alloc() : memref<7x7xf16>
    %0 = scf.for %arg0 = %idx0 to %idx1 step %idx1 iter_args(%arg1 = %alloc) -> (memref<7x7xf16>) {
 linalg.copy ins(%alloc : memref<7x7xf16>) outs(%arg1 : memref<7x7xf16>)
 scf.yield %alloc : memref<7x7xf16>
    }
    return
  }
}
```
The above MLIR program will cause a crash when using the following command:
```
mlir-opt --loop-invariant-subset-hoisting test.mlir
```
And the crash backtrace is:
```
mlir-opt: /data/tmp/v0302/llvm-project/build/tools/mlir/include/mlir/Interfaces/DestinationStyleOpInterface.h.inc:147: mlir::OpResult mlir::DestinationStyleOpInterface::getTiedOpResult(mlir::OpOperand*): Assertion `resultIndex >= 0 && resultIndex < (*this)->getNumResults()' 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/tmp/v0302/llvm-project/build/bin/mlir-opt --loop-invariant-subset-hoisting test.mlir
 #0 0x000055fc235b42af llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x168d2af)
 #1 0x000055fc235b1304 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f43c2e33420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f43c290000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f43c28df859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f43c28df729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f43c28f0fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000055fc2a06c423 mlir::detail::defaultGetUpdatedDestination(mlir::Operation*) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x8145423)
 #8 0x000055fc24489dee mlir::detail::SubsetInsertionOpInterfaceInterfaceTraits::FallbackModel<(anonymous namespace)::LinalgCopyOpInterface>::getUpdatedDestination(mlir::detail::SubsetInsertionOpInterfaceInterfaceTraits::Concept const*, mlir::Operation*) SubsetInsertionOpInterfaceImpl.cpp:0:0
 #9 0x000055fc26647143 (anonymous namespace)::MatchingSubsets::populateSubsetOpsAtIterArg(mlir::LoopLikeOpInterface, mlir::BlockArgument, bool) (.constprop.0) LoopInvariantCodeMotionUtils.cpp:0:0
#10 0x000055fc26648882 hoistSubsetAtIterArg(mlir::RewriterBase&, mlir::LoopLikeOpInterface, mlir::BlockArgument) LoopInvariantCodeMotionUtils.cpp:0:0
#11 0x000055fc26649476 mlir::hoistLoopInvariantSubsets(mlir::RewriterBase&, mlir::LoopLikeOpInterface) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x4722476)
#12 0x000055fc265b9292 _ZN4llvm12function_refIFvPN4mlir9OperationEEE11callback_fnIZNS1_6detail4walkILNS1_9WalkOrderE1ENS1_15ForwardIteratorEZN12_GLOBAL__N_127LoopInvariantSubsetHoisting14runOnOperationEvEUlNS1_19LoopLikeOpInterfaceEE_SD_vEENSt9enable_ifIXaantsrSt11disjunctionIJSt7is_sameIT2_S3_ESH_ISI_PNS1_6RegionEESH_ISI_PNS1_5BlockEEEE5valuesrSH_IT3_vE5valueESR_E4typeES3_OT1_EUlS3_E_EEvlS3_ LoopInvariantCodeMotion.cpp:0:0
#13 0x000055fc265b852c void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (.constprop.2) LoopInvariantCodeMotion.cpp:0:0
#14 0x000055fc265b97da (anonymous namespace)::LoopInvariantSubsetHoisting::runOnOperation() LoopInvariantCodeMotion.cpp:0:0
#15 0x000055fc26578df1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x4651df1)
#16 0x000055fc2657929a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x465229a)
#17 0x000055fc26579e34 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x4652e34)
#18 0x000055fc2656b48b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x000055fc2656bef2 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#20 0x000055fc2656c164 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&)::'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
#21 0x000055fc26670a1e 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/tmp/v0302/llvm-project/build/bin/mlir-opt+0x4749a1e)
#22 0x000055fc26562d79 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x463bd79)
#23 0x000055fc2656c2d1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x46452d1)
#24 0x000055fc2656c796 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x4645796)
#25 0x000055fc234cecab main (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x15a7cab)
#26 0x00007f43c28e1083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#27 0x000055fc2358502e _start (/data/tmp/v0302/llvm-project/build/bin/mlir-opt+0x165e02e)
Aborted (core dumped)
```
My git version is b6d5fa05ada6e51ede32c62ff47f046ca5085d28.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to