Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mlir] --normalize-memrefs crashes in Utils.cpp:1217:mlir::affine::replaceAllMemRefUsesWith #121091

Open
Emilyaxe opened this issue Dec 25, 2024 · 1 comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:affine

Comments

@Emilyaxe
Copy link

git version: 7d166fa

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)
@github-actions github-actions bot added the mlir label Dec 25, 2024
@EugeneZelenko EugeneZelenko added mlir:affine crash Prefer [crash-on-valid] or [crash-on-invalid] and removed mlir labels Dec 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 25, 2024

@llvm/issue-subscribers-mlir-affine

Author: None (Emilyaxe)

git version: 7d166fa

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt a.mlir --normalize-memrefs

a.mlir:

module {
  func.func @<!-- -->func3(%arg0: index, %arg1: memref&lt;1x10x17xi32, strided&lt;[?, ?, ?], offset: ?&gt;&gt;, %arg2: memref&lt;1x10x17xi32, strided&lt;[?, ?, ?], offset: ?&gt;&gt;, %arg3: memref&lt;1x10x17xi32, strided&lt;[?, ?, ?], offset: ?&gt;&gt;) -&gt; (memref&lt;1x5xf32, strided&lt;[17, 1], offset: 27&gt;&gt;, memref&lt;1x5xf32, strided&lt;[17, 1], offset: 27&gt;&gt;, memref&lt;2x17xf32&gt;, memref&lt;1x10x17xi32&gt;, memref&lt;1x10x17xf32&gt;) {
    %alloc = memref.alloc() {alignment = 64 : i64} : memref&lt;1x10x17xi32&gt;
    %alloc_0 = memref.alloc() {alignment = 64 : i64} : memref&lt;2x17xf32&gt;
    %alloc_1 = memref.alloc() {alignment = 64 : i64} : memref&lt;1x10x17xf32&gt;
    cf.br ^bb3
  ^bb3:  // pred: ^bb1
    %reinterpret_cast = memref.reinterpret_cast %alloc_0 to offset: [27], sizes: [1, 5], strides: [17, 1] : memref&lt;2x17xf32&gt; to memref&lt;1x5xf32, strided&lt;[17, 1], offset: 27&gt;&gt;
    return %reinterpret_cast, %reinterpret_cast, %alloc_0, %alloc, %alloc_1 : memref&lt;1x5xf32, strided&lt;[17, 1], offset: 27&gt;&gt;, memref&lt;1x5xf32, strided&lt;[17, 1], offset: 27&gt;&gt;, memref&lt;2x17xf32&gt;, memref&lt;1x10x17xi32&gt;, memref&lt;1x10x17xf32&gt;
  }
}

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&lt;Value&gt;, AffineMap, ArrayRef&lt;Value&gt;, ArrayRef&lt;Value&gt;, bool): Assertion `false &amp;&amp; "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&amp;, 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&lt;mlir::Value&gt;, mlir::AffineMap, llvm::ArrayRef&lt;mlir::Value&gt;, llvm::ArrayRef&lt;mlir::Value&gt;, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368009)
#<!-- -->10 0x00005564193f2670 mlir::affine::replaceAllMemRefUsesWith(mlir::Value, mlir::Value, llvm::ArrayRef&lt;mlir::Value&gt;, mlir::AffineMap, llvm::ArrayRef&lt;mlir::Value&gt;, llvm::ArrayRef&lt;mlir::Value&gt;, mlir::Operation*, mlir::Operation*, bool, bool) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1368670)
#<!-- -->11 0x000055641ab97113 void llvm::function_ref&lt;void (mlir::Operation*)&gt;::callback_fn&lt;(anonymous namespace)::NormalizeMemRefs::normalizeFuncOpMemRefs(mlir::func::FuncOp, mlir::ModuleOp)::$_2&gt;(long, mlir::Operation*) NormalizeMemRefs.cpp:0:0
#<!-- -->12 0x00005564193914ce void mlir::detail::walk&lt;mlir::ForwardIterator&gt;(mlir::Operation*, llvm::function_ref&lt;void (mlir::Operation*)&gt;, 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&amp;, 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&amp;, std::shared_ptr&lt;llvm::SourceMgr&gt; const&amp;, mlir::MLIRContext*, mlir::MlirOptMainConfig const&amp;) MlirOptMain.cpp:0:0
#<!-- -->18 0x000055641c1d618d llvm::LogicalResult llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::raw_ostream&amp;)&gt;::callback_fn&lt;mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;)::$_0&gt;(long, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::raw_ostream&amp;) MlirOptMain.cpp:0:0
#<!-- -->19 0x000055641c281c65 mlir::splitAndProcessBuffer(std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::function_ref&lt;llvm::LogicalResult (std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, llvm::raw_ostream&amp;)&gt;, llvm::raw_ostream&amp;, llvm::StringRef, llvm::StringRef) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41f7c65)
#<!-- -->20 0x000055641c1d0175 mlir::MlirOptMain(llvm::raw_ostream&amp;, std::unique_ptr&lt;llvm::MemoryBuffer, std::default_delete&lt;llvm::MemoryBuffer&gt;&gt;, mlir::DialectRegistry&amp;, mlir::MlirOptMainConfig const&amp;) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4146175)
#<!-- -->21 0x000055641c1d041f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&amp;) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414641f)
#<!-- -->22 0x000055641c1d074e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&amp;) (/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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mlir:affine
Projects
None yet
Development

No branches or pull requests

3 participants