llvm-project
llvm-project copied to clipboard
[Mlir] --normalize-memrefs crashes in Utils.cpp:1217:mlir::affine::replaceAllMemRefUsesWith
git version: 7d166fa38470
system: Ubuntu 18.04.6 LTS
reproduce with: mlir-opt a.mlir --normalize-memrefs
a.mlir:
module {
func.func @func3(%arg0: index, %arg1: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>, %arg2: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>, %arg3: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>) -> (memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<2x17xf32>, memref<1x10x17xi32>, memref<1x10x17xf32>) {
%alloc = memref.alloc() {alignment = 64 : i64} : memref<1x10x17xi32>
%alloc_0 = memref.alloc() {alignment = 64 : i64} : memref<2x17xf32>
%alloc_1 = memref.alloc() {alignment = 64 : i64} : memref<1x10x17xf32>
cf.br ^bb3
^bb3: // pred: ^bb1
%reinterpret_cast = memref.reinterpret_cast %alloc_0 to offset: [27], sizes: [1, 5], strides: [17, 1] : memref<2x17xf32> to memref<1x5xf32, strided<[17, 1], offset: 27>>
return %reinterpret_cast, %reinterpret_cast, %alloc_0, %alloc, %alloc_1 : memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<2x17xf32>, memref<1x10x17xi32>, memref<1x10x17xf32>
}
}
stack trace:
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/Dialect/Affine/Utils/Utils.cpp:1217: LogicalResult mlir::affine::replaceAllMemRefUsesWith(Value, Value, Operation *, ArrayRef<Value>, AffineMap, ArrayRef<Value>, ArrayRef<Value>, bool): Assertion `false && "multiple dereferencing uses in a single op not supported"' 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 tosa.mlir --normalize-memrefs
#0 0x0000556419279508 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ef508)
#1 0x000055641927701e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ed01e)
#2 0x0000556419279e9d SignalHandler(int) Signals.cpp:0:0
#3 0x00007fd566871420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fd565eae00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#5 0x00007fd565e8d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#6 0x00007fd565e8d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#7 0x00007fd565e8d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#8 0x00007fd565e9efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#9 0x00005564193f2009 mlir::affine::replaceAllMemRefUsesWith(mlir::Value, mlir::Value, mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::AffineMap, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368009)
#10 0x00005564193f2670 mlir::affine::replaceAllMemRefUsesWith(mlir::Value, mlir::Value, llvm::ArrayRef<mlir::Value>, mlir::AffineMap, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, mlir::Operation*, mlir::Operation*, bool, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368670)
#11 0x000055641ab97113 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp)::$_2>(long, mlir::Operation*) NormalizeMemRefs.cpp:0:0
#12 0x00005564193914ce 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+0x13074ce)
#13 0x000055641ab949ff (anonymous namespace)::NormalizeMemRefs::runOnOperation() NormalizeMemRefs.cpp:0:0
#14 0x000055641c1daec6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4150ec6)
#15 0x000055641c1db7f0 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+0x41517f0)
#16 0x000055641c1dddc2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4153dc2)
#17 0x000055641c1d653a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055641c1d618d 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
#19 0x000055641c281c65 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+0x41f7c65)
#20 0x000055641c1d0175 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+0x4146175)
#21 0x000055641c1d041f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414641f)
#22 0x000055641c1d074e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414674e)
#23 0x0000556419259ff7 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfff7)
#24 0x00007fd565e8f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x0000556419259b6e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfb6e)
@llvm/issue-subscribers-mlir-affine
Author: None (Emilyaxe)
git version: 7d166fa38470
system: Ubuntu 18.04.6 LTS
reproduce with: mlir-opt a.mlir --normalize-memrefs
a.mlir:
module {
func.func @<!-- -->func3(%arg0: index, %arg1: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>, %arg2: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>, %arg3: memref<1x10x17xi32, strided<[?, ?, ?], offset: ?>>) -> (memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<2x17xf32>, memref<1x10x17xi32>, memref<1x10x17xf32>) {
%alloc = memref.alloc() {alignment = 64 : i64} : memref<1x10x17xi32>
%alloc_0 = memref.alloc() {alignment = 64 : i64} : memref<2x17xf32>
%alloc_1 = memref.alloc() {alignment = 64 : i64} : memref<1x10x17xf32>
cf.br ^bb3
^bb3: // pred: ^bb1
%reinterpret_cast = memref.reinterpret_cast %alloc_0 to offset: [27], sizes: [1, 5], strides: [17, 1] : memref<2x17xf32> to memref<1x5xf32, strided<[17, 1], offset: 27>>
return %reinterpret_cast, %reinterpret_cast, %alloc_0, %alloc, %alloc_1 : memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<1x5xf32, strided<[17, 1], offset: 27>>, memref<2x17xf32>, memref<1x10x17xi32>, memref<1x10x17xf32>
}
}
stack trace:
mlir-opt: /data/szy/MLIR/llvm-release/llvm-project/mlir/lib/Dialect/Affine/Utils/Utils.cpp:1217: LogicalResult mlir::affine::replaceAllMemRefUsesWith(Value, Value, Operation *, ArrayRef<Value>, AffineMap, ArrayRef<Value>, ArrayRef<Value>, bool): Assertion `false && "multiple dereferencing uses in a single op not supported"' 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 tosa.mlir --normalize-memrefs
#<!-- -->0 0x0000556419279508 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ef508)
#<!-- -->1 0x000055641927701e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ed01e)
#<!-- -->2 0x0000556419279e9d SignalHandler(int) Signals.cpp:0:0
#<!-- -->3 0x00007fd566871420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#<!-- -->4 0x00007fd565eae00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
#<!-- -->5 0x00007fd565e8d859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
#<!-- -->6 0x00007fd565e8d729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
#<!-- -->7 0x00007fd565e8d729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
#<!-- -->8 0x00007fd565e9efd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#<!-- -->9 0x00005564193f2009 mlir::affine::replaceAllMemRefUsesWith(mlir::Value, mlir::Value, mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::AffineMap, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368009)
#<!-- -->10 0x00005564193f2670 mlir::affine::replaceAllMemRefUsesWith(mlir::Value, mlir::Value, llvm::ArrayRef<mlir::Value>, mlir::AffineMap, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Value>, mlir::Operation*, mlir::Operation*, bool, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368670)
#<!-- -->11 0x000055641ab97113 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp)::$_2>(long, mlir::Operation*) NormalizeMemRefs.cpp:0:0
#<!-- -->12 0x00005564193914ce 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+0x13074ce)
#<!-- -->13 0x000055641ab949ff (anonymous namespace)::NormalizeMemRefs::runOnOperation() NormalizeMemRefs.cpp:0:0
#<!-- -->14 0x000055641c1daec6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4150ec6)
#<!-- -->15 0x000055641c1db7f0 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+0x41517f0)
#<!-- -->16 0x000055641c1dddc2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4153dc2)
#<!-- -->17 0x000055641c1d653a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#<!-- -->18 0x000055641c1d618d 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
#<!-- -->19 0x000055641c281c65 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+0x41f7c65)
#<!-- -->20 0x000055641c1d0175 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+0x4146175)
#<!-- -->21 0x000055641c1d041f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414641f)
#<!-- -->22 0x000055641c1d074e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414674e)
#<!-- -->23 0x0000556419259ff7 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfff7)
#<!-- -->24 0x00007fd565e8f083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#<!-- -->25 0x0000556419259b6e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfb6e)
This PR fixes this issue.
This PR fixes this issue.
Thank you for the kind reminder. However, this crash can still be reproduced in version 18c43d01fc6. Could you please take another look?
The PR has not been merged yet. cc @bondhugula