Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mlir] --affine-loop-fusion="mode=producer fusion-maximal" crashes in LoopFusion.cpp:301: createPrivateMemRef #121020

Open
Emilyaxe opened this issue Dec 24, 2024 · 0 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir

Comments

@Emilyaxe
Copy link

git version: 7b23f41

system: Ubuntu 18.04.6 LTS

reproduce with: /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir --affine-loop-fusion="mode=producer fusion-maximal"

a.mlir:

#map = affine_map<()[s0] -> (s0 + 5)>
#map1 = affine_map<()[s0] -> (s0 + 17)>
module {
  func.func private @func2() {
    %0 = llvm.mlir.constant(2 : index) : i64
    %2 = llvm.mlir.constant(0 : index) : i64
    %3 = builtin.unrealized_conversion_cast %2 : i64 to index
    %alloc = memref.alloc() {alignment = 64 : i64} : memref<8x18xf32>
    %alloc_1 = memref.alloc() {alignment = 64 : i64} : memref<3xf32>
    %alloc_2 = memref.alloc() {alignment = 64 : i64} : memref<3xindex>
    affine.for %arg3 = 0 to 3 {
      %4 = affine.load %alloc_2[%arg3] : memref<3xindex>
      %5 = builtin.unrealized_conversion_cast %4 : index to i64
      %6 = llvm.sub %0, %5 : i64
      %7 = builtin.unrealized_conversion_cast %6 : i64 to index
      affine.store %7, %alloc_2[%arg3] : memref<3xindex>
    }
    affine.for %arg3 = 0 to 3 {
      %4 = affine.load %alloc_2[%arg3] : memref<3xindex>
      %5 = affine.apply #map()[%4]
      %6 = affine.apply #map1()[%3]
      %7 = memref.load %alloc[%5, %6] : memref<8x18xf32>
      affine.store %7, %alloc_1[%arg3] : memref<3xf32>
    }
    return
  }
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp:301: Value createPrivateMemRef(AffineForOp, Operation *, unsigned int, std::optional<unsigned int>, uint64_t): Assertion `eltSize && "memrefs with size elt types expected"' 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 a.mlir "--affine-loop-fusion=mode=producer fusion-maximal"
 #0 0x000056305543f508 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ef508)
 #1 0x000056305543d01e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ed01e)
 #2 0x000056305543fe9d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fa8a5f02420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fa8a553f00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fa8a551e859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007fa8a551e729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007fa8a551e729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007fa8a552ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000056305556a052 (anonymous namespace)::GreedyFusion::performFusionsIntoDest(unsigned int, unsigned int) LoopFusion.cpp:0:0
#10 0x0000563055566105 (anonymous namespace)::GreedyFusion::fuseProducerConsumerNodes(unsigned int) LoopFusion.cpp:0:0
#11 0x0000563055565bae void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::LoopFusion::runOnOperation()::$_0>(long, mlir::Operation*) LoopFusion.cpp:0:0
#12 0x00005630555574ce void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x13074ce)
#13 0x0000563055562f2a (anonymous namespace)::LoopFusion::runOnOperation() LoopFusion.cpp:0:0
#14 0x00005630583a0ec6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4150ec6)
#15 0x00005630583a17f0 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+0x41517f0)
#16 0x00005630583a3dc2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4153dc2)
#17 0x000056305839c53a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000056305839c18d 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
#19 0x0000563058447c65 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+0x41f7c65)
#20 0x0000563058396175 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+0x4146175)
#21 0x000056305839641f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414641f)
#22 0x000056305839674e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414674e)
#23 0x000056305541fff7 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfff7)
#24 0x00007fa8a5520083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x000056305541fb6e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfb6e)
@github-actions github-actions bot added the mlir label Dec 24, 2024
@EugeneZelenko EugeneZelenko added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir
Projects
None yet
Development

No branches or pull requests

2 participants