<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61342>61342</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]Crashed on `-convert-scf-to-openmp` with`<unknown>:0: error: invalid pointer element type: 'index'`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BealZephyr
</td>
</tr>
</table>
<pre>
Test on [llvm16](https://github.com/llvm/llvm-project/tree/release/16.x)
steps to reproduce:
```
mlir-opt -convert-scf-to-openmp test.mlir
```
test case:
```
func.func @single_iteration_reduce(%A: index, %B: index) -> (index, index) {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c2 = arith.constant 2 : index
%c3 = arith.constant 3 : index
%c6 = arith.constant 6 : index
%0:2 = scf.parallel (%i0, %i1) = (%c1, %c3) to (%c2, %c6) step (%c1, %c3) init(%A, %B) -> (index, index) {
scf.reduce(%i0) : index {
^bb0(%lhs: index, %rhs: index):
%1 = arith.addi %lhs, %rhs : index
scf.reduce.return %1 : index
}
scf.reduce(%i1) : index {
^bb0(%lhs: index, %rhs: index):
%2 = arith.muli %lhs, %rhs : index
scf.reduce.return %2 : index
}
scf.yield
}
return %0#0, %0#1 : index, index
}
```
crash trace:
```
<unknown>:0: error: invalid pointer element type: 'index'
mlir-opt: /home/ty/llvm16/mlir/include/mlir/IR/StorageUniquerSupport.h:153: static ConcreteT mlir::detail::StorageUserBase<mlir::LLVM::LLVMPointerType, mlir::Type, mlir::LLVM::detail::LLVMPointerTypeStorage, mlir::detail::TypeUniquer, Trait, Trait>::get(mlir::MLIRContext *, Args...) [ConcreteT = mlir::LLVM::LLVMPointerType, BaseT = mlir::Type, StorageT = mlir::LLVM::detail::LLVMPointerTypeStorage, UniquerT = mlir::detail::TypeUniquer, Traits = <Trait, Trait>, Args = <mlir::Type, unsigned int>]: Assertion `succeeded(ConcreteT::verify(getDefaultDiagnosticEmitFn(ctx), args...))' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/ty/llvm16/llvm/mlir/build/bin/mlir-opt -convert-scf-to-openmp test.mlir
#0 0x0000000000481d7d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/ty/llvm16/llvm/lib/Support/Unix/Signals.inc:567:11
#1 0x000000000048220b PrintStackTraceSignalHandler(void*) /home/ty/llvm16/llvm/lib/Support/Unix/Signals.inc:641:1
#2 0x00000000004805a6 llvm::sys::RunSignalHandlers() /home/ty/llvm16/llvm/lib/Support/Signals.cpp:104:5
#3 0x0000000000482935 SignalHandler(int) /home/ty/llvm16/llvm/lib/Support/Unix/Signals.inc:412:1
#4 0x00007f94fd2a0980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#5 0x00007f94fc190e87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#6 0x00007f94fc1927f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#7 0x00007f94fc1823fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#8 0x00007f94fc182472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#9 0x00000000017c6c7d mlir::LLVM::LLVMPointerType mlir::detail::StorageUserBase<mlir::LLVM::LLVMPointerType, mlir::Type, mlir::LLVM::detail::LLVMPointerTypeStorage, mlir::detail::TypeUniquer, mlir::DataLayoutTypeInterface::Trait, mlir::SubElementTypeInterface::Trait>::get<mlir::Type, unsigned int>(mlir::MLIRContext*, mlir::Type, unsigned int) /home/ty/llvm16/mlir/include/mlir/IR/StorageUniquerSupport.h:152:5
#10 0x00000000017bf35b mlir::LLVM::LLVMPointerType::get(mlir::Type, unsigned int) /home/ty/llvm16/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp:250:10
#11 0x000000000307ca35 addAtomicRMW(mlir::OpBuilder&, mlir::LLVM::AtomicBinOp, mlir::omp::ReductionDeclareOp, mlir::scf::ReduceOp) /home/ty/llvm16/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp:223:18
#12 0x000000000307b894 declareReduction(mlir::PatternRewriter&, mlir::scf::ReduceOp) /home/ty/llvm16/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp:270:12
#13 0x000000000307a87c (anonymous namespace)::ParallelOpLowering::matchAndRewrite(mlir::scf::ParallelOp, mlir::PatternRewriter&) const /home/ty/llvm16/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp:349:38
#14 0x0000000000a0e11b mlir::detail::OpOrInterfaceRewritePatternBase<mlir::scf::ParallelOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /home/ty/llvm16/mlir/include/mlir/IR/PatternMatch.h:330:12
#15 0x0000000004a54ee0 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&)>) /home/ty/llvm16/mlir/lib/Rewrite/PatternApplicator.cpp:200:25
#16 0x0000000003b10ec0 (anonymous namespace)::OperationLegalizer::legalizeWithPattern(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:1987:21
#17 0x0000000003b105db (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:1895:17
#18 0x0000000003b0fb1f (anonymous namespace)::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:2406:26
#19 0x0000000003b073ab (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:2455:16
#20 0x0000000003b07077 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:3360:22
#21 0x0000000003b075ee mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) /home/ty/llvm16/mlir/lib/Transforms/Utils/DialectConversion.cpp:3366:10
#22 0x000000000307a157 (anonymous namespace)::applyPatterns(mlir::ModuleOp) /home/ty/llvm16/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp:449:10
#23 0x0000000003079f26 (anonymous namespace)::SCFToOpenMPPass::runOnOperation() /home/ty/llvm16/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp:456:16
#24 0x0000000003a697a7 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/ty/llvm16/mlir/lib/Pass/Pass.cpp:471:21
#25 0x0000000003a69dbd mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/ty/llvm16/mlir/lib/Pass/Pass.cpp:534:16
#26 0x0000000003a6b6fc mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/ty/llvm16/mlir/lib/Pass/Pass.cpp:839:10
#27 0x0000000003a6b621 mlir::PassManager::run(mlir::Operation*) /home/ty/llvm16/mlir/lib/Pass/Pass.cpp:819:60
#28 0x0000000003a61f82 performActions(llvm::raw_ostream&, bool, bool, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, bool, bool) /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:91:17
#29 0x0000000003a61bdf processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, bool, bool, bool, bool, bool, bool, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, llvm::ThreadPool*) /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:139:12
#30 0x0000000003a61998 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:181:12
#31 0x0000000003a6188d 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>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /home/ty/llvm16/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#32 0x0000000003b93ae9 llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/ty/llvm16/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#33 0x0000000003b930c5 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) /home/ty/llvm16/mlir/lib/Support/ToolUtilities.cpp:28:12
#34 0x0000000003a608c3 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (mlir::PassManager&)>, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool) /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:186:10
#35 0x0000000003a60a5f mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::PassPipelineCLParser const&, mlir::DialectRegistry&, bool, bool, bool, bool, bool, bool, bool, bool) /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:209:10
#36 0x0000000003a616a1 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) /home/ty/llvm16/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:306:14
#37 0x00000000004116d9 main /home/ty/llvm16/mlir/tools/mlir-opt/mlir-opt.cpp:271:7
#38 0x00007f94fc173c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#39 0x00000000004113ba _start (/home/ty/llvm16/llvm/mlir/build/bin/mlir-opt+0x4113ba)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW9tu4zjSfhrmhoghkTpe5M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