<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/73288>73288</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir] --convert-linalg-to-affine-loops crashed
</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: ba89749cd24950c9c51f4cc64277ce0421d86d20
system: Ubuntu 20.04.6 LTS (Focal Fossa)
reproduced with: ```mlir-opt --convert-linalg-to-affine-loops a.mlir```
a.mlir:
```
#map = affine_map<(d0)[s0] -> (d0 mod s0)>
#map1 = affine_map<(d0)[s0] -> (d0 floordiv s0)>
llvm.func @malloc(i64) -> !llvm.ptr
func.func @func1(%arg0: memref<3xi32, #spirv.storage_class<StorageBuffer>>) {
%c16 = arith.constant 16 : index
%0 = llvm.mlir.constant(0 : index) : i64
%1 = llvm.mlir.constant(1 : index) : i64
%2 = llvm.mlir.constant(64 : index) : i64
%idx0 = index.constant 0
%20 = llvm.mlir.constant(13101 : i16) : i16
%44 = llvm.mlir.constant(26 : index) : i64
%57 = llvm.mlir.constant(16 : index) : i64
%80 = builtin.unrealized_conversion_cast %idx0 : index to i64
%120 = llvm.mul %80, %57 : i64
%121 = llvm.mul %120, %44 : i64
%122 = llvm.mlir.zero : !llvm.ptr
%123 = llvm.getelementptr %122[%121] : (!llvm.ptr, i64) -> !llvm.ptr, i16
%124 = llvm.ptrtoint %123 : !llvm.ptr to i64
%125 = llvm.add %124, %2 : i64
%126 = llvm.call @malloc(%125) : (i64) -> !llvm.ptr
%127 = llvm.ptrtoint %126 : !llvm.ptr to i64
%128 = llvm.sub %2, %1 : i64
%129 = llvm.add %127, %128 : i64
%130 = llvm.urem %129, %2 : i64
%131 = llvm.sub %129, %130 : i64
%132 = llvm.inttoptr %131 : i64 to !llvm.ptr
%133 = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%134 = llvm.insertvalue %126, %133[0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%135 = llvm.insertvalue %132, %134[1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%136 = llvm.insertvalue %0, %135[2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%137 = llvm.insertvalue %44, %136[3, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%138 = llvm.insertvalue %80, %137[3, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%139 = llvm.insertvalue %57, %138[3, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%140 = llvm.insertvalue %120, %139[4, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%141 = llvm.insertvalue %57, %140[4, 1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%142 = llvm.insertvalue %1, %141[4, 2] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
%143 = builtin.unrealized_conversion_cast %142 : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> to memref<?x?x16xi16>
affine.for %arg1 = 0 to 0 {
%224 = affine.apply #map(%arg1)[%c16]
%225 = affine.apply #map1(%arg1)[%c16]
%226 = affine.apply #map(%225)[%idx0]
%227 = affine.apply #map1(%225)[%idx0]
affine.store %20, %143[%227, %226, %224] : memref<?x?x16xi16>
}
llvm.return
}
```
trace:
```
LLVM ERROR: can't create Attribute 'mlir::ub::PoisonAttr' because storage uniquer isn't initialized: the dialect was likely not loaded, or the attribute wasn't added with addAttributes<...>() in the Dialect::initialize() method.
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 --convert-linalg-to-affine-loops a.mlir
#0 0x000055f045d3b01f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x160201f)
#1 0x000055f045d38074 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f85a64cf420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f85a5fba00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f85a5f99859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x000055f045c4a2aa llvm::vfs::RedirectingFileSystem::create(llvm::ArrayRef<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, bool, llvm::vfs::FileSystem&) (.cold) VirtualFileSystem.cpp:0:0
#6 0x000055f045def56b mlir::affine::AffineApplyOp::fold(mlir::affine::AffineApplyOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (/data/bin/llvm-project/build/bin/mlir-opt+0x16b656b)
#7 0x000055f045def64d mlir::LogicalResult llvm::detail::UniqueFunctionBase<mlir::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::affine::AffineApplyOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::IndexType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::VariadicOperands, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>(void*, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x16b664d)
#8 0x000055f045e40a36 mlir::RegisteredOperationName::Model<mlir::affine::AffineApplyOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x1707a36)
#9 0x000055f048b38492 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x43ff492)
#10 0x000055f048b387d8 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x43ff7d8)
#11 0x000055f0489dede2 mlir::OperationFolder::tryToFold(mlir::Operation*, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a5de2)
#12 0x000055f0489e21dd (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#13 0x000055f0489e66cb mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42ad6cb)
#14 0x000055f04696e8bc void (anonymous namespace)::lowerLinalgToLoopsImpl<mlir::affine::AffineForOp>(mlir::Operation*) Loops.cpp:0:0
#15 0x000055f04892c8ee mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x41f38ee)
#16 0x000055f04892cdca 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+0x41f3dca)
#17 0x000055f04892d5f4 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41f45f4)
#18 0x000055f04891e363 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#19 0x000055f04891f834 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
#20 0x000055f04891f9e4 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
#21 0x000055f048a1ecd4 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+0x42e5cd4)
#22 0x000055f048918247 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+0x41df247)
#23 0x000055f04891fb31 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41e6b31)
#24 0x000055f04891ff96 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41e6f96)
#25 0x000055f045c725eb main (/data/bin/llvm-project/build/bin/mlir-opt+0x15395eb)
#26 0x00007f85a5f9b083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#27 0x000055f045d0b37e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x15d237e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcW91T47iW_2vMi4qULfnzgYcAnXu7ChYKuL1V-5KSreOgbUXySjJN5q_fkuU4dkiAvvQwPXdqmmD7fPzOh47OkQM1hq8kwFmQnAfJ5Qlt7aPSZ1QquVmr1lxf3J-Uim3OVtyiJ9CGKxmQOSppXmRxUTEcF0lYFVUS1XFVpTHOsgrCGEcsTxkOg_AyCOf-p9kYC2vH_a-ylbZFOJyF8SxFVw_3KMD5QlVUoIUyhga4GHNqaLRibQUM_eD20YkI0tD_vxZcn6rGotPTSskn0PZUcEnF6tSqU1rXXMKpUKoxiM4c7cA4VtA_Iv3lPg0ma9qggFwiL3C5pk1ALgKcs9BBTc5NGCSX6DQgX1B3F60VQ6Z7SL6MpUQ_J6YWSmnGn_ZkCfG0ntWtrFAQh2sqhKoCnPM0DnCxZY86osZqz-KoBxb3GQU4D3BC9Sp0Dl3DWkMdkAvyzAkO8AUKMDEN108zY5WmK1hWghoTkIt7f33e1jVoh4l8cXqD7NyrQijASRWl3lTN7eOsUtJYKi3q7s4RlwyeR9RhR9shdpEY6AOchyMGp8VdpHHPG-AkOs4avcbqePFx3jR-i5mzZw-7o9mZGI4VvGJYRKKwRxilg4ooHbHH8XF2nL4FMMleUf4md-6hly0XlstZKzVQwf8AtvTrzJWCZUWNHfmiF4is2hMWTRzRCq_AZ5nDeUB_hKMXLBHe8sTxYZ79iP4BWnWEL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