llvm / llvm-project

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

[mlir][affine] -affine-data-copy-generate crashes in BuiltinTypes.cpp:525: unsigned int mlir::detail::getMemorySpaceAsInt(Attribute): Assertion `llvm::isa<IntegerAttr>(memorySpace) && "Using `getMemorySpaceInteger` with non-Integer attribute"' failed. #108369

Open axeabc opened 1 month ago

axeabc commented 1 month ago

git version: 8168088f0a9015b

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -affine-data-copy-generate a.mlir

a.mlir:

#map = affine_map<(d0) -> (d0)>
module {
  func.func @load_store() {
    %cst = arith.constant 8.000000e-01 : f32
    %alloc_0 = memref.alloc() : memref<10xf32, #spirv.storage_class<StorageBuffer>>
    affine.for %arg0 = 0 to 10 {
      affine.for %arg1 = #map(%arg0) to #map(%arg0) {
        %0 = affine.load %alloc_0[%arg1] : memref<10xf32, #spirv.storage_class<StorageBuffer>>
        affine.store %cst, %alloc_0[%arg1] : memref<10xf32, #spirv.storage_class<StorageBuffer>>
      }
    }
    return
  }
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/IR/BuiltinTypes.cpp:525: unsigned int mlir::detail::getMemorySpaceAsInt(Attribute): Assertion `llvm::isa<IntegerAttr>(memorySpace) && "Using `getMemorySpaceInteger` with non-Integer attribute"' 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 -affine-data-copy-generate a.mlir
 #0 0x000056375957e2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10dc2c8)
 #1 0x000056375957bdde llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d9dde)
 #2 0x000056375957ec5d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f35c9c17420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f35c925400b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f35c9233859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f35c9233729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f35c9233729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f35c9244fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000056375c7d43b5 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x43323b5)
#10 0x00005637596d63bc void llvm::function_ref<void (mlir::Operation*)>::callback_fn<mlir::affine::affineDataCopyGenerate(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, mlir::affine::AffineCopyOptions const&, std::optional<mlir::Value>, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&)::$_0>(long, mlir::Operation*) LoopUtils.cpp:0:0
#11 0x000056375968284e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11e084e)
#12 0x000056375968284e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11e084e)
#13 0x00005637596cb595 mlir::affine::affineDataCopyGenerate(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, mlir::affine::AffineCopyOptions const&, std::optional<mlir::Value>, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1229595)
#14 0x0000563759682268 (anonymous namespace)::AffineDataCopyGeneration::runOnBlock(mlir::Block*, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&) AffineDataCopyGeneration.cpp:0:0
#15 0x000056375967f029 (anonymous namespace)::AffineDataCopyGeneration::runOnOperation() AffineDataCopyGeneration.cpp:0:0
#16 0x000056375c6a5156 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 0x000056375c6a5ac0 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 0x000056375c6aae7e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#19 0x000056375c6a719b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x420519b)
#20 0x000056375c6a52a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42032a8)
#21 0x000056375c6a5ac0 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)
#22 0x000056375c6a8102 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4206102)
#23 0x000056375c6a0931 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#24 0x000056375c6a058b 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
#25 0x000056375c74cf25 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)
#26 0x000056375c69b9b5 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)
#27 0x000056375c69bc5f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9c5f)
#28 0x000056375c69bf8e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9f8e)
#29 0x000056375955ef07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bcf07)
#30 0x00007f35c9235083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#31 0x000056375955ea8e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bca8e)
llvmbot commented 1 month ago

@llvm/issue-subscribers-mlir-affine

Author: None (axeabc)

git version: 8168088f0a9015b system: `Ubuntu 18.04.6 LTS` reproduce with: `mlir-opt -affine-data-copy-generate a.mlir` a.mlir: ``` #map = affine_map<(d0) -> (d0)> module { func.func @load_store() { %cst = arith.constant 8.000000e-01 : f32 %alloc_0 = memref.alloc() : memref<10xf32, #spirv.storage_class<StorageBuffer>> affine.for %arg0 = 0 to 10 { affine.for %arg1 = #map(%arg0) to #map(%arg0) { %0 = affine.load %alloc_0[%arg1] : memref<10xf32, #spirv.storage_class<StorageBuffer>> affine.store %cst, %alloc_0[%arg1] : memref<10xf32, #spirv.storage_class<StorageBuffer>> } } return } } ``` stack trace: ``` mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/IR/BuiltinTypes.cpp:525: unsigned int mlir::detail::getMemorySpaceAsInt(Attribute): Assertion `llvm::isa<IntegerAttr>(memorySpace) && "Using `getMemorySpaceInteger` with non-Integer attribute"' 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 -affine-data-copy-generate a.mlir #0 0x000056375957e2c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10dc2c8) #1 0x000056375957bdde llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10d9dde) #2 0x000056375957ec5d SignalHandler(int) Signals.cpp:0:0 #3 0x00007f35c9c17420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420) #4 0x00007f35c925400b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1 #5 0x00007f35c9233859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7 #6 0x00007f35c9233729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8 #7 0x00007f35c9233729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34 #8 0x00007f35c9244fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6) #9 0x000056375c7d43b5 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x43323b5) #10 0x00005637596d63bc void llvm::function_ref<void (mlir::Operation*)>::callback_fn<mlir::affine::affineDataCopyGenerate(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, mlir::affine::AffineCopyOptions const&, std::optional<mlir::Value>, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&)::$_0>(long, mlir::Operation*) LoopUtils.cpp:0:0 #11 0x000056375968284e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11e084e) #12 0x000056375968284e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11e084e) #13 0x00005637596cb595 mlir::affine::affineDataCopyGenerate(llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, llvm::ilist_iterator<llvm::ilist_detail::node_options<mlir::Operation, true, false, void, false, void>, false, false>, mlir::affine::AffineCopyOptions const&, std::optional<mlir::Value>, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1229595) #14 0x0000563759682268 (anonymous namespace)::AffineDataCopyGeneration::runOnBlock(mlir::Block*, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>&) AffineDataCopyGeneration.cpp:0:0 #15 0x000056375967f029 (anonymous namespace)::AffineDataCopyGeneration::runOnOperation() AffineDataCopyGeneration.cpp:0:0 #16 0x000056375c6a5156 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 0x000056375c6a5ac0 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 0x000056375c6aae7e mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0 #19 0x000056375c6a719b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x420519b) #20 0x000056375c6a52a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x42032a8) #21 0x000056375c6a5ac0 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) #22 0x000056375c6a8102 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4206102) #23 0x000056375c6a0931 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0 #24 0x000056375c6a058b 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 #25 0x000056375c74cf25 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) #26 0x000056375c69b9b5 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) #27 0x000056375c69bc5f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9c5f) #28 0x000056375c69bf8e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f9f8e) #29 0x000056375955ef07 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bcf07) #30 0x00007f35c9235083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3 #31 0x000056375955ea8e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x10bca8e) ```