Skip to content

[mlir] -inline crashes in BuiltinTypeInterfaces.h.inc:242: bool mlir::detail::ShapedTypeTrait<mlir::MemRefType>::isDynamicDim(unsigned int) const [ConcreteType = mlir::MemRefType]: Assertion `idx < getRank() && "invalid index for shaped type"' failed. #108371

Open
@anonymoususer-12

Description

@anonymoususer-12

git version: 8168088

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -inline a.mlir

-canonicalize also crashes

a.mlir:

module {
  func.func private @callee(%i: index, %j: index, %k: index, %m: memref<?xf32>) {
    %c0 = arith.constant 0 : index
    %c0_0 = arith.constant 0 : index
    %dim = memref.dim %m, %c0_0 : memref<?xf32>
    %0 = arith.cmpi sge, %i, %c0 : index
    %1 = arith.cmpi slt, %i, %dim : index
    %2 = arith.andi %0, %1 : i1
    %c1 = arith.constant 1 : index
    %dim_1 = memref.dim %m, %c1 : memref<?xf32>
    %3 = arith.cmpi sge, %j, %c0 : index
    %4 = arith.cmpi slt, %j, %dim_1 : index
    %5 = arith.andi %3, %4 : i1
    %6 = arith.andi %2, %5 : i1
    cf.assert %6, "ERROR: Runtime op verification failed\0A%12 = \22memref.load\22(%2, %3, %4) : (memref<?xf32>, index, index) -> f32\0A^ out-of-bounds access\0ALocation: loc(\22/data/szy/MLIR/seed729/tmp.Jv59r4jk.mlir\22:8:12)"
    %7 = memref.load %m[%i] : memref<?xf32>
    gpu.barrier
    return
  }
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinTypeInterfaces.h.inc:242: bool mlir::detail::ShapedTypeTrait<mlir::MemRefType>::isDynamicDim(unsigned int) const [ConcreteType = mlir::MemRefType]: Assertion `idx < getRank() && "invalid index for shaped type"' 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 -inline a.mlir
 #0 0x00005615507f82c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10dc2c8)
 #1 0x00005615507f5dde llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d9dde)
 #2 0x00005615507f8c5d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f49b0fc5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f49b060200b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f49b05e1859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f49b05e1729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f49b05e1729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f49b05f2fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x00005615508bb44b mlir::detail::ShapedTypeTrait<mlir::MemRefType>::isDynamicDim(unsigned int) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x119f44b)
#10 0x0000561550fa0e2d (anonymous namespace)::SimplifyDimOfAllocOp::matchAndRewrite(mlir::memref::DimOp, mlir::PatternRewriter&) const GPUDialect.cpp:0:0
#11 0x000056155631b5b1 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
#12 0x000056155631826b 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+0x6bfc26b)
#13 0x000056155399a65f (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#14 0x0000561553996e8f mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x427ae8f)
#15 0x000056155393cb2b (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#16 0x000056155391f156 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203156)
#17 0x000056155391fac0 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+0x4203ac0)
#18 0x00005615539241e6 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_0>(long, mlir::OpPassManager&, mlir::Operation*) Pass.cpp:0:0
#19 0x000056155399bb34 mlir::Inliner::Impl::optimizeCallable(mlir::CallGraphNode*, llvm::StringMap<mlir::OpPassManager, llvm::MallocAllocator>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x427fb34)
#20 0x00005615539a2221 mlir::Inliner::Impl::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*)::$_0::operator()(mlir::CallGraphNode*) const Inliner.cpp:0:0
#21 0x000056155399b97c mlir::Inliner::Impl::optimizeSCCAsync(llvm::MutableArrayRef<mlir::CallGraphNode*>, mlir::MLIRContext*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x427f97c)
#22 0x000056155399c510 mlir::Inliner::doInlining() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4280510)
#23 0x0000561553945575 (anonymous namespace)::InlinerPass::runOnOperation() InlinerPass.cpp:0:0
#24 0x000056155391f156 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4203156)
#25 0x000056155391fac0 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+0x4203ac0)
#26 0x0000561553922102 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4206102)
#27 0x000056155391a931 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#28 0x000056155391a58b 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
#29 0x00005615539c6f25 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+0x42aaf25)
#30 0x00005615539159b5 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+0x41f99b5)
#31 0x0000561553915c5f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9c5f)
#32 0x0000561553915f8e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9f8e)
#33 0x00005615507d8f07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bcf07)
#34 0x00007f49b05e3083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#35 0x00005615507d8a8e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bca8e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlirmlir:memref

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions