<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114769>114769</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]--pass-pipeline="builtin.module(func.func(test-match-reduction))" triggers Assertion Failure `Index < this->size() && "Invalid index!"'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xisang0
</td>
</tr>
</table>
<pre>
Test on commit: [c3edeaa61bf0e7faed6c26f693b4fcd9102ba1ec](url)
steps to reproduce:
```
mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(test-match-reduction))"
```
test case:
```
#map1 = affine_map<(d0, d1, d2, d3) -> (d3)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
module {
func.func @main(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<1x32x32x8xf32>, %arg2: tensor<16x2x2x8xf32>, %arg3: tensor<16xf32>){
%cst = arith.constant 0.000000e+00 : f32
%2 = tensor.empty() : tensor<1x8226x33x8xf32>
%3 = linalg.fill ins(%cst : f32) outs(%2 : tensor<1x8226x33x8xf32>) -> tensor<1x8226x33x8xf32>
%inserted_slice = tensor.insert_slice %arg1 into %3[0, 8193, 0, 0] [1, 32, 32, 8] [1, 1, 1, 1] : tensor<1x32x32x8xf32> into tensor<1x8226x33x8xf32>
%4 = tensor.empty() : tensor<1x32x32x16xf32>
%5 = linalg.generic {indexing_maps = [#map1, #map2], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg3 : tensor<16xf32>) outs(%4 : tensor<1x32x32x16xf32>) {
^bb0(%in: f32, %out: f32):
linalg.yield %in : f32
} -> tensor<1x32x32x16xf32>
%6 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%inserted_slice, %arg2 : tensor<1x8226x33x8xf32>, tensor<16x2x2x8xf32>) outs(%5 : tensor<1x32x32x16xf32>) -> tensor<1x32x32x16xf32>
return
}
}
```
crash trace:
```
mlir-opt: /home/workdir/llvm-project-19/llvm/include/llvm/ADT/ArrayRef.h:446: T &llvm::MutableArrayRef<mlir::OpOperand>::operator[](size_t) const [T = mlir::OpOperand]: Assertion `Index < this->size() && "Invalid index!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ./mlir-opt /home/workdir/test9.mlir --pass-pipeline=builtin.module(func.func(test-match-reduction))
#0 0x000064f72867d228 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./mlir-opt+0x1062228)
#1 0x000064f72867ad4e llvm::sys::RunSignalHandlers() (./mlir-opt+0x105fd4e)
#2 0x000064f72867dc38 SignalHandler(int) Signals.cpp:0:0
#3 0x0000793393543520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007933935979fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000793393543476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007933935297f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000079339352971b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000079339353ae96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x000064f728a959cb (./mlir-opt+0x147a9cb)
#10 0x000064f72b882afa mlir::matchReduction(llvm::ArrayRef<mlir::BlockArgument>, unsigned int, llvm::SmallVectorImpl<mlir::Operation*>&) (./mlir-opt+0x4267afa)
#11 0x000064f72b35a055 void llvm::function_ref<void (mlir::Operation*)>::callback_fn<(anonymous namespace)::TestMatchReductionPass::runOnOperation()::'lambda'(mlir::Operation*)>(long, mlir::Operation*) TestMatchReduction.cpp:0:0
#12 0x000064f728783a06 void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x1168a06)
#13 0x000064f728783a9e void mlir::detail::walk<mlir::ForwardIterator>(mlir::Operation*, llvm::function_ref<void (mlir::Operation*)>, mlir::WalkOrder) (./mlir-opt+0x1168a9e)
#14 0x000064f72b359e49 (anonymous namespace)::TestMatchReductionPass::runOnOperation() TestMatchReduction.cpp:0:0
#15 0x000064f72b8a5e9f mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x428ae9f)
#16 0x000064f72b8a6682 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x428b682)
#17 0x000064f72b8abd9e auto void mlir::parallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&&)::'lambda'(__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>&&)::operator()<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&>(__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>&&) const Pass.cpp:0:0
#18 0x000064f72b8a7e8b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (./mlir-opt+0x428ce8b)
#19 0x000064f72b8a5ffc mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (./mlir-opt+0x428affc)
#20 0x000064f72b8a6682 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (./mlir-opt+0x428b682)
#21 0x000064f72b8a8e2e mlir::PassManager::run(mlir::Operation*) (./mlir-opt+0x428de2e)
#22 0x000064f72b8a1952 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x000064f72b8a15bb 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
#24 0x000064f72b94b2a5 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) (./mlir-opt+0x43302a5)
#25 0x000064f72b89c7b2 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (./mlir-opt+0x42817b2)
#26 0x000064f72b89ca63 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4281a63)
#27 0x000064f72b89cc72 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (./mlir-opt+0x4281c72)
#28 0x000064f72865c477 main (./mlir-opt+0x1041477)
#29 0x000079339352ad90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x000079339352ae40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x000064f72865bfe5 _start (./mlir-opt+0x1040fe5)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWltv2zgW_jXMCxFDInV9yINjJ9gAEyRIi91Hg6IomxuK1JJU6-yvX5D0RXKsJul0ZnaKBq5qi4fn8p0LjygSY_haMnYF0muQLi9IbzdKX225IXIdXVSqfrn6zIyFSkKq2pZbgOcQpNcUs5oRksVVE7G8IazOKMqarMRV0tC6jCNUkZhR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