<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64066>64066</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] "mlir::RewriterBase::replaceOp" crashed with Assertion failure ""incorrect # of replacement values""
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Colloportus0
</td>
</tr>
</table>
<pre>
MLIR built at commit 585cbe3f
Reproduced with:
`mlir-opt -pass-pipeline='builtin.module(async-func-to-async-runtime,async-to-async-runtime)' temp.mlir`
temp.mlir:
``` milr
module {
func.func nested @func1(%arg0: index, %arg1: memref<?x?xi32>, %arg2: index) {
%c20895_i16 = arith.constant 20895 : i16
%c2 = arith.constant 2 : index
%c31 = arith.constant 31 : index
%21 = vector.broadcast %c20895_i16 : i16 to vector<14xi16>
%false_22 = arith.constant false
scf.index_switch %c2
default {
scf.if %false_22 {
%143 = vector.insertelement %c20895_i16, %21[%c31 : index] : vector<14xi16>
}
}
return
}
}
```
trace:
```console
Assertion failed: (idx < size()), function operator[], file SmallVector.h, line 294.
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 -pass-pipeline=builtin.module(async-func-to-async-runtime,async-to-async-runtime) temp.mlir
#0 0x0000000104704f18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/workspace/build/bin/mlir-opt+0x1002f8f18)
#1 0x00000001047031b4 llvm::sys::RunSignalHandlers() (/workspace/build/bin/mlir-opt+0x1002f71b4)
#2 0x00000001047055c4 SignalHandler(int) (/workspace/build/bin/mlir-opt+0x1002f95c4)
#3 0x00000001be7894c4 (/usr/lib/system/libsystem_platform.dylib+0x1803414c4)
#4 0x00000001be771ee0 (/usr/lib/system/libsystem_pthread.dylib+0x180329ee0)
#5 0x00000001be6ac340 (/usr/lib/system/libsystem_c.dylib+0x180264340)
#6 0x00000001be6ab754 (/usr/lib/system/libsystem_c.dylib+0x180263754)
#7 0x0000000108ade2dc mlir::vector::InsertElementOp::fold(mlir::vector::InsertElementOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (.cold.7) (/workspace/build/bin/mlir-opt+0x1046d22dc)
#8 0x00000001063a91a0 mlir::vector::InsertElementOp::fold(mlir::vector::InsertElementOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (/workspace/build/bin/mlir-opt+0x101f9d1a0)
#9 0x0000000106420050 mlir::LogicalResult mlir::Op<mlir::vector::InsertElementOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::VectorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::AtLeastNOperands<2u>::Impl, mlir::OpTrait::OpInvariants, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::InferTypeOpInterface::Trait>::foldSingleResultHook<mlir::vector::InsertElementOp>(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/workspace/build/bin/mlir-opt+0x102014050)
#10 0x000000010641f2f4 mlir::RegisteredOperationName::Model<mlir::vector::InsertElementOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/workspace/build/bin/mlir-opt+0x1020132f4)
#11 0x0000000106eb01e4 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/workspace/build/bin/mlir-opt+0x102aa41e4)
#12 0x0000000106e00468 mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (/workspace/build/bin/mlir-opt+0x1029f4468)
#13 0x0000000106da4a20 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) (/workspace/build/bin/mlir-opt+0x102998a20)
#14 0x0000000106d9d15c (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) (/workspace/build/bin/mlir-opt+0x10299115c)
#15 0x0000000106d9f2a4 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/workspace/build/bin/mlir-opt+0x1029932a4)
#16 0x0000000104a49e94 (anonymous namespace)::AsyncToAsyncRuntimePass::runOnOperation() (/workspace/build/bin/mlir-opt+0x10063de94)
#17 0x0000000106d542a8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/workspace/build/bin/mlir-opt+0x1029482a8)
#18 0x0000000106d54998 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/workspace/build/bin/mlir-opt+0x102948998)
#19 0x0000000106d5682c mlir::PassManager::run(mlir::Operation*) (/workspace/build/bin/mlir-opt+0x10294a82c)
#20 0x0000000106d4ed14 performActions(llvm::raw_ostream&, std::__1::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x102942d14)
#21 0x0000000106d4e368 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_1>(long, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) (/workspace/build/bin/mlir-opt+0x102942368)
#22 0x0000000106dcc34c mlir::splitAndProcessBuffer(std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/workspace/build/bin/mlir-opt+0x1029c034c)
#23 0x0000000106d48d1c mlir::MlirOptMain(llvm::raw_ostream&, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/workspace/build/bin/mlir-opt+0x10293cd1c)
#24 0x0000000106d4918c mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/workspace/build/bin/mlir-opt+0x10293d18c)
#25 0x000000010440f510 main (/workspace/build/bin/mlir-opt+0x100003510)
#26 0x000000010fc35088
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWk1T47jW_jVmo-qULcmJvWCRDuQdqpqBgq5ZvBtKkY8T3ZYlX0luyPz6W5KdxEqAgdTU3LnTRZPYPtJ5nvOlIxlmrVgrgMsk_5rkVxescxttLhdaSt1q4zqbXqx0tb28_XbzgFadkA4xh7huGuEQyoucr4DUSXqVpPMHaI2uOg4VehZuk5A5Qv2TZJo2UpgvunXoS8us_dKKFqRQkJCrBM_CxEJNGl11EhJcMLtV_EvdKf7F6S_9lemUEw0keNFfnz4oEzxDDpp24rUl03TQHn4f7pP5HlX_gxohTX8P9RBQMvs63EAexcT_QgqsgwolNPWXWYKLBOfMrFNPVagKXhK8QP29zN9roDFQJ2SRkOWL_y8ITsj1QQqPRpYjpQnOOU6LMn8S2RQl5AoxI9xmwrWyjimHwkMURmfTHVLUj3tVHu01oVicZK_Jh7uvDsC9_E_gTpvJymhWcWbdCeSADDk9SCZ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