Skip to content

[mlir] Crash when using --finalize-memref-to-llvm #111242

@AnonymousBugreporter1

Description

@AnonymousBugreporter1

I have the following MLIR program:
test.mlir:

func.func @func1()  {
  %alloc_0 = memref.alloc() {alignment = 64 : i64} : memref<10xf32, 1 : ui64>
  return 
}

The above MLIR program will cause a crash when using the following command:

mlir-opt --finalize-memref-to-llvm test.mlir

And the crash backtrace is:

mlir-opt: /data/tmp/v1005/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:360: int64_t mlir::IntegerAttr::getInt() const: Assertion `(getType().isIndex() || getType().isSignlessInteger()) && "must be signless integer"' 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/tmp/v1005/llvm-project/build/bin/mlir-opt --finalize-memref-to-llvm test.mlir
 #0 0x000055ebc9fd543f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x158443f)
 #1 0x000055ebc9fd24a4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f4571282420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f4570d4f00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f4570d2e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f4570d2e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f4570d3ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000055ebcd3bd0dd mlir::IntegerAttr::getInt() const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x496c0dd)
 #8 0x000055ebcc8b9237 mlir::LLVMTypeConverter::getMemRefAddressSpace(mlir::BaseMemRefType) const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x3e68237)
 #9 0x000055ebcc8af947 mlir::ConvertToLLVMPattern::getElementPtrType(mlir::MemRefType) const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x3e5e947)
#10 0x000055ebcc97eb70 mlir::AllocationOpLLVMLowering::allocateBufferManuallyAlign(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Value, mlir::Operation*, mlir::Value) const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x3f2db70)
#11 0x000055ebcc963a83 (anonymous namespace)::AllocOpLowering::allocateBuffer(mlir::ConversionPatternRewriter&, mlir::Location, mlir::Value, mlir::Operation*) const MemRefToLLVM.cpp:0:0
#12 0x000055ebcc97fbf7 mlir::AllocLikeOpLLVMLowering::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x3f2ebf7)
#13 0x000055ebcd2ff7ea mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48ae7ea)
#14 0x000055ebd04a0dc0 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/tmp/v1005/llvm-project/build/bin/mlir-opt+0x7a4fdc0)
#15 0x000055ebcd3078bb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x000055ebcd308efe mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48b7efe)
#17 0x000055ebcd30c86b mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48bb86b)
#18 0x000055ebcd30ec59 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48bdc59)
#19 0x000055ebcc97621f (anonymous namespace)::FinalizeMemRefToLLVMConversionPass::runOnOperation() MemRefToLLVM.cpp:0:0
#20 0x000055ebcd2644f1 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48134f1)
#21 0x000055ebcd2649ca mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x48139ca)
#22 0x000055ebcd265514 mlir::PassManager::run(mlir::Operation*) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x4814514)
#23 0x000055ebcd256a1b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000055ebcd2573e4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) MlirOptMain.cpp:0:0
#25 0x000055ebcd257594 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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#26 0x000055ebcd36004e 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/tmp/v1005/llvm-project/build/bin/mlir-opt+0x490f04e)
#27 0x000055ebcd24ee39 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x47fde39)
#28 0x000055ebcd257701 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x4806701)
#29 0x000055ebcd257bc6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x4806bc6)
#30 0x000055ebc9eecacb main (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x149bacb)
#31 0x00007f4570d30083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x000055ebc9fa862e _start (/data/tmp/v1005/llvm-project/build/bin/mlir-opt+0x155762e)
Aborted (core dumped)

My git version is bf895c7.

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions