llvm / llvm-project

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

[mlir] -convert-memref-to-emitc crashes #109648

Closed axeabc closed 1 month ago

axeabc commented 1 month ago

git version: c3d3cef8d5837

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -convert-memref-to-emitc a.mlir

a.mlir:

module {
  func.func private @f() -> (f16 {test.A}, f16 {test2.B})
  memref.global "private" constant @__constant_2x4 : memref<2x4xf16> = dense<2.000000e+00>
}

stack trace:

<unknown>:0: error: dimensions must have positive size
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/include/mlir/IR/StorageUniquerSupport.h:180: static ConcreteT mlir::detail::StorageUserBase<mlir::emitc::ArrayType, mlir::Type, mlir::emitc::detail::ArrayTypeStorage, mlir::detail::TypeUniquer, mlir::ShapedType::Trait>::get(MLIRContext *, Args &&...) [ConcreteT = mlir::emitc::ArrayType, BaseT = mlir::Type, StorageT = mlir::emitc::detail::ArrayTypeStorage, UniquerT = mlir::detail::TypeUniquer, Traits = <mlir::ShapedType::Trait>, Args = <llvm::ArrayRef<long> &, mlir::Type &>]: Assertion `succeeded( ConcreteT::verifyInvariants(getDefaultDiagnosticEmitFn(ctx), args...))' 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 -convert-memref-to-emitc a.mlir
 #0 0x000055b27be6e458 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1100458)
 #1 0x000055b27be6bf6e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10fdf6e)
 #2 0x000055b27be6eded SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f0da1345420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f0da098200b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f0da0961859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f0da0961729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f0da0961729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f0da0972fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000055b27c486a74 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1718a74)
#10 0x000055b27c4869a1 mlir::emitc::ArrayType::get(llvm::ArrayRef<long>, mlir::Type) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x17189a1)
#11 0x000055b27e89b370 std::_Function_handler<std::optional<llvm::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&), std::enable_if<std::is_invocable_v<mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0, mlir::MemRefType, llvm::SmallVectorImpl<mlir::Type>&>, std::function<std::optional<llvm::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::MemRefType, std::enable_if<std::is_invocable_v<mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0, mlir::MemRefType>, std::function<std::optional<llvm::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::MemRefType, mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0>(mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0&&) const::'lambda'(mlir::MemRefType, llvm::SmallVectorImpl<mlir::Type>&)>(mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0&&) const::'lambda'(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>::_M_invoke(std::_Any_data const&, mlir::Type&&, llvm::SmallVectorImpl<mlir::Type>&) MemRefToEmitC.cpp:0:0
#12 0x000055b27f057e4d mlir::TypeConverter::convertType(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42e9e4d)
#13 0x000055b27f0599d7 mlir::TypeConverter::convertType(mlir::Type) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42eb9d7)
#14 0x000055b27e89c501 (anonymous namespace)::ConvertGlobal::matchAndRewrite(mlir::memref::GlobalOp, mlir::memref::GlobalOpAdaptor, mlir::ConversionPatternRewriter&) const MemRefToEmitC.cpp:0:0
#15 0x000055b27e89c22d mlir::OpConversionPattern<mlir::memref::GlobalOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3b2e22d)
#16 0x000055b27f05ca61 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42eea61)
#17 0x000055b281a19e21 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
#18 0x000055b281a16aeb 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+0x6ca8aeb)
#19 0x000055b27f05daa3 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#20 0x000055b27f05cb07 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42eeb07)
#21 0x000055b27f05dccf mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42efccf)
#22 0x000055b27f0650ab mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42f70ab)
#23 0x000055b27e899e3e (anonymous namespace)::ConvertMemRefToEmitCPass::runOnOperation() MemRefToEmitCPass.cpp:0:0
#24 0x000055b27effe8e6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42908e6)
#25 0x000055b27efff250 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+0x4291250)
#26 0x000055b27f0017f2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42937f2)
#27 0x000055b27effa0d1 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#28 0x000055b27eff9d2b 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 0x000055b27f0a54e5 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+0x43374e5)
#30 0x000055b27eff5155 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+0x4287155)
#31 0x000055b27eff53ff mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42873ff)
#32 0x000055b27eff572e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x428772e)
#33 0x000055b27be4efe7 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10e0fe7)
#34 0x00007f0da0963083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#35 0x000055b27be4eb6e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10e0b6e)
CoTinker commented 1 month ago

Sorry, I can't reproduce it.

axeabc commented 1 month ago

Sorry, I can't reproduce it.

This issue has been fixed in the latest version. I will close this issue.