Skip to content

[mlir] -finalize-memref-to-llvm crashes #119856

@Anonymous7i0em3yd

Description

@Anonymous7i0em3yd

git version: bc29fc9

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -finalize-memref-to-llvm a.mlir

a.mlir:

#map = affine_map<(d0) -> (d0 + 1)>
module {
  llvm.func @malloc(%arg0: i64) ->!llvm.struct<(ptr, ptr, i64)> {
    %alloc = memref.alloc() : memref<1024x64xf32>
    %0 = builtin.unrealized_conversion_cast %alloc : memref<1024x64xf32> to!llvm.struct<(ptr, ptr, i64)>
    llvm.return %0 :!llvm.struct<(ptr, ptr, i64)>
  }
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From &) [To = mlir::LLVM::LLVMPointerType, From = mlir::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible 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 -finalize-memref-to-llvm /data/szy/MLIR/seed/seed0/tmp.1XEffPECLs.mlir
 #0 0x000055f80c4e5348 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x111f348)
 #1 0x000055f80c4e2e5e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x111ce5e)
 #2 0x000055f80c4e5cdd SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f65c64bb420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f65c5af800b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f65c5ad7859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f65c5ad7729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f65c5ad7729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f65c5ae8fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000055f80f1492c0 castAllocFuncResult(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Value, mlir::MemRefType, mlir::Type, mlir::LLVMTypeConverter const&) AllocLikeConversion.cpp:0:0
#10 0x000055f80f149081 mlir::AllocationOpLLVMLowering::allocateBufferManuallyAlign(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Value, mlir::Operation*, mlir::Value) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3d83081)
#11 0x000055f80f14896d (anonymous namespace)::AllocOpLowering::allocateBuffer(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Value, mlir::Operation*) const MemRefToLLVM.cpp:0:0
#12 0x000055f80f149a40 mlir::AllocLikeOpLLVMLowering::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x3d83a40)
#13 0x000055f80c7e2124 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x141c124)
#14 0x000055f80f44d644 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4087644)
#15 0x000055f8124b6591 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
#16 0x000055f8124b325b 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+0x70ed25b)
#17 0x000055f80f44e713 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#18 0x000055f80f44d767 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4087767)
#19 0x000055f80f44e93f mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x408893f)
#20 0x000055f80f454afb mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x408eafb)
#21 0x000055f80f12e2db (anonymous namespace)::FinalizeMemRefToLLVMConversionPass::runOnOperation() MemRefToLLVM.cpp:0:0
#22 0x000055f80f3f03d6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x402a3d6)
#23 0x000055f80f3f0d00 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+0x402ad00)
#24 0x000055f80f3f32d2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x402d2d2)
#25 0x000055f80f3eba4a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x000055f80f3eb69d 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
#27 0x000055f80f497235 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+0x40d1235)
#28 0x000055f80f3e5685 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+0x401f685)
#29 0x000055f80f3e592f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x401f92f)
#30 0x000055f80f3e5c5e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x401fc5e)
#31 0x000055f80c4c5e37 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10ffe37)
#32 0x00007f65c5ad9083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x000055f80c4c59ae _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10ff9ae)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions