Skip to content

[mlir] [memref] -convert-memref-to-emitc crashes in mlir::emitc::ArrayType with assertion failed "succeeded( ConcreteT::verifyInvariants(getDefaultDiagnosticEmitFn(ctx), args...))" #103706

Closed
@anonymoususer-1

Description

@anonymoususer-1

git version: b68df

system: Ubuntu 18.04.6 LTS

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

It seems that the convert-memref-to-emitcpass does not consider the illegal types, such asf16or i4.
Both the f16or i4 in memref will triger the crash when converting to emitc.

a.mlir:

func.func @memref_store(%v : f16, %i: index, %j: index) {
  %0 = memref.alloca() : memref<4x8xf16>
  memref.store %v, %0[%i, %j] : memref<4x8xf16>
  return
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-debug/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-debug/llvm-project/build/bin/mlir-opt b.mlir -convert-memref-to-emitc
 #0 0x0000560c68c047c9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x0000560c68c04c7b PrintStackTraceSignalHandler(void*) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x0000560c68c02eaf llvm::sys::RunSignalHandlers() /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x0000560c68c0534e SignalHandler(int) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007fe76aeae420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007fe76a4eb00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007fe76a4ca859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007fe76a4ca729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007fe76a4ca729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007fe76a4dbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x0000560c6976e19f mlir::emitc::ArrayType mlir::detail::StorageUserBase<mlir::emitc::ArrayType, mlir::Type, mlir::emitc::detail::ArrayTypeStorage, mlir::detail::TypeUniquer, mlir::ShapedType::Trait>::get<llvm::ArrayRef<long>&, mlir::Type&>(mlir::MLIRContext*, llvm::ArrayRef<long>&, mlir::Type&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/IR/StorageUniquerSupport.h:179:5
#11 0x0000560c6972e1ed mlir::emitc::ArrayType::get(llvm::ArrayRef<long>, mlir::Type) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Dialect/EmitC/IR/EmitCTypes.cpp.inc:126:10
#12 0x0000560c6d19c511 mlir::populateMemRefToEmitCTypeConversion(mlir::TypeConverter&)::$_0::operator()(mlir::MemRefType) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitC.cpp:182:16
#13 0x0000560c6d19c359 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>&)::operator()(mlir::MemRefType, llvm::SmallVectorImpl<mlir::Type>&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/Transforms/DialectConversion.h:359:43
#14 0x0000560c6d19c2fc 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>&)::operator()(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/Transforms/DialectConversion.h:380:14
#15 0x0000560c6d19c1a8 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>&) /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/std_function.h:285:9
#16 0x0000560c6e02c60e std::function<std::optional<llvm::LogicalResult> (mlir::Type, llvm::SmallVectorImpl<mlir::Type>&)>::operator()(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) const /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/std_function.h:688:14
#17 0x0000560c6e00ad61 mlir::TypeConverter::convertType(mlir::Type, llvm::SmallVectorImpl<mlir::Type>&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2956:47
#18 0x0000560c6e00c39a mlir::TypeConverter::convertType(mlir::Type) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2977:14
#19 0x0000560c6d19ceb0 (anonymous namespace)::ConvertAlloca::matchAndRewrite(mlir::memref::AllocaOp, mlir::memref::AllocaOpAdaptor, mlir::ConversionPatternRewriter&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitC.cpp:43:41
#20 0x0000560c6d1a0ee0 mlir::OpConversionPattern<mlir::memref::AllocaOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/Transforms/DialectConversion.h:544:12
#21 0x0000560c6e00e58e mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1650:10
#22 0x0000560c71f0f53f 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::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:212:31
#23 0x0000560c71f0f3b5 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) /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#24 0x0000560c68c287f9 llvm::function_ref<void ()>::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#25 0x0000560c71f10bbb void mlir::MLIRContext::executeAction<mlir::ApplyPatternAction, mlir::Pattern const&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pattern const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/IR/MLIRContext.h:276:3
#26 0x0000560c71f0df53 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-debug/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:233:9
#27 0x0000560c6e016254 (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1958:21
#28 0x0000560c6e00ec03 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1850:17
#29 0x0000560c6e00e5f3 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2384:26
#30 0x0000560c6e00eee1 mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2436:16
#31 0x0000560c6e013389 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3429:22
#32 0x0000560c6e01348d mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3435:10
#33 0x0000560c6d19b1fc (anonymous namespace)::ConvertMemRefToEmitCPass::runOnOperation() /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitCPass.cpp:50:16
#34 0x0000560c6df49b94 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#35 0x0000560c6df49b35 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#36 0x0000560c68c287f9 llvm::function_ref<void ()>::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#37 0x0000560c6df4c8bb void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/IR/MLIRContext.h:276:3
#38 0x0000560c6df45720 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:533:17
#39 0x0000560c6df45c37 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:593:16
#40 0x0000560c6df47558 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:904:10
#41 0x0000560c6df4748d mlir::PassManager::run(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:884:60
#42 0x0000560c6df3be1d performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:413:17
#43 0x0000560c6df3ba82 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:478:12
#44 0x0000560c6df3b87c mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:561:12
#45 0x0000560c6df3b816 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&) /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#46 0x0000560c6e0b6e22 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#47 0x0000560c6e0b6435 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-debug/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:12
#48 0x0000560c6df38703 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:564:10
#49 0x0000560c6df38aa5 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:605:14
#50 0x0000560c6df38c78 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:621:10
#51 0x0000560c68b8ec53 main /data/szy/MLIR/llvm-debug/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:317:33
#52 0x00007fe76a4cc083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#53 0x0000560c68b8e87e _start (/data/szy/MLIR/llvm-debug/llvm-project/build/bin/mlir-opt+0x24ad87e)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions