<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68483>68483</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][memref] --fold-memref-alias-ops crashed with assertion failure "sizes must be nonnegative"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anonymousMCS
</td>
</tr>
</table>
<pre>
git version: 3a3b84b180278207731451dfac24f47d02b50e84
system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```
reproduced with: ```mlir-opt --fold-memref-alias-ops a.mlir```
a.mlir:
```
func.func @func2() {
%c0 = arith.constant 0 : index
%c16 = arith.constant 16 : index
%c23 = arith.constant 23 : index
%alloc = memref.alloc(%c23, %c16) {alignment = 64 : i64} : memref<?x?xi1>
%collapse_shape = memref.collapse_shape %alloc [[0, 1]] : memref<?x?xi1> into memref<?xi1>
%103 = memref.load %collapse_shape[%c0] : memref<?xi1>
vector.print %103 : i1
return
}
```
trace:
```
mlir-opt: /data/bin/llvm-project/mlir/lib/Dialect/Utils/IndexingUtils.cpp:73: llvm::SmallVector<long int> mlir::computeSuffixProduct(llvm::ArrayRef<long int>): Assertion `llvm::all_of(sizes, [](int64_t s) { return s > 0; }) && "sizes must be nonnegative"' 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/bin/llvm-project/build/bin/mlir-opt --fold-memref-alias-ops a.mlir
#0 0x0000563eaabda33f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x159633f)
#1 0x0000563eaabd73d4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fb5a0e54420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007fb5a093f00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007fb5a091e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007fb5a091e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007fb5a092ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x0000563eaf89682e mlir::computeSuffixProduct(llvm::ArrayRef<long>) (/data/bin/llvm-project/build/bin/mlir-opt+0x625282e)
#8 0x0000563eabdf69ff resolveSourceIndicesCollapseShape(mlir::Location, mlir::PatternRewriter&, mlir::memref::CollapseShapeOp, mlir::ValueRange, llvm::SmallVectorImpl<mlir::Value>&) FoldMemRefAliasOps.cpp:0:0
#9 0x0000563eabe0683c (anonymous namespace)::LoadOpOfCollapseShapeOpFolder<mlir::memref::LoadOp>::matchAndRewrite(mlir::memref::LoadOp, mlir::PatternRewriter&) const FoldMemRefAliasOps.cpp:0:0
#10 0x0000563eb0326038 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6ce2038)
#11 0x0000563ead71903c (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#12 0x0000563ead71d4ab mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x40d94ab)
#13 0x0000563eabdfa43a (anonymous namespace)::FoldMemRefAliasOpsPass::runOnOperation() FoldMemRefAliasOps.cpp:0:0
#14 0x0000563ead661e1e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x401de1e)
#15 0x0000563ead6622fa mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x401e2fa)
#16 0x0000563ead662b24 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x401eb24)
#17 0x0000563ead6533eb performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x0000563ead6548a4 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#19 0x0000563ead654a54 mlir::LogicalResult llvm::function_ref<mlir::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
#20 0x0000563ead752ce4 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x410ece4)
#21 0x0000563ead64dd27 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4009d27)
#22 0x0000563ead654d7b mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x4010d7b)
#23 0x0000563eaab1323b main (/data/bin/llvm-project/build/bin/mlir-opt+0x14cf23b)
#24 0x00007fb5a0920083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#25 0x0000563eaabaaede _start (/data/bin/llvm-project/build/bin/mlir-opt+0x1566ede)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWV1T4zjW_jXmRkVKlvyVCy4MdN6XqqagoGf2MiVbx4l2ZMkryQzMr9-S7AQ7hCbTdM3OblcTgn306Hw85-hIYtaKjQK4iNLLKL0-Y73banPBlFYvre7t7dXjWaX5y8VGOPQExgqtIloiymhVJFVcYJIXBOc5jZM05g2rSdIkOcekSjEUSYSvI1wOn_bFOmj96CjDw_9fql65HhG8wMkiQ1-_PaKIFCtdM4lW2loWkeVeeIploDOa9zVw9Ltw2xloK4U5151D5-eNlvy8hdZAc86kYPZcdxaxhRc5iju-ouX04YFk06t64T9QlGD_m0SkiMgSRfnlIIFQRNIao4heI2aE2y5qraxjyiH_sERCcXieysbZMeHw9Ig0ocekw9O30kxKXQf5wRGL8CCo7JEicjVqMJrApNioFpQLY7JkAM2SKL8OXweUiF5FdPXsf0Qc0S_jhB5JS8k6C2u7ZR1MJz58s9fNc-8Se03iKL2O0u9NhIRyev5uqoBHjTGdTis1428V85P6IB2dbYr4BLXTZtEZ4V2yQy-RiEcBA643aqRKfn2UM8OnM6yG75NrR97AaLLizLGIrCqhIrKS8qk974z-J9QuIqvAVLKSoorI6lowOTz-xQlpI7K68TwQahP-XtRdF9Eypx7X43gtaPnYMil_DQZG9EpqtfHu9V7epQEta912vYPHvmnE833IOheR4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