llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.69k stars 11.87k forks source link

Error in Lowering MLIR scf::ParallelOp #59918

Open amanchhaparia opened 1 year ago

amanchhaparia commented 1 year ago

I am trying to lower the following IR but getting the following error. IR:

func.func @TEST_func(%in : memref<?xf32>, %out : memref<?xf32>){
   %c0 = arith.constant 0 : index
   %c1 = arith.constant 1 : index
    %dim = memref.dim %in, %c0 : memref<?xf32>
    scf.parallel (%arg0) = (%c0) to (%dim) step (%c1) {
      %2 = memref.load %in[%arg0] : memref<?xf32>
      memref.store %2, %out[%arg0] : memref<?xf32>
    }
    return
}

Lowering pass:

../../llvm/build/bin/mlir-opt test.mlir  -async-parallel-for -async-to-async-runtime -async-runtime-ref-counting -async-runtime-ref-counting-opt -arith-expand -convert-async-to-llvm -lower-affine -convert-scf-to-cf -convert-memref-to-llvm -convert-vector-to-llvm -convert-func-to-llvm --llvm-request-c-wrappers -reconcile-unrealized-casts | ../../llvm/build/bin/mlir-translate --mlir-to-llvmir | ../../llvm/build/bin/llc -mtriple=x86_64-unknown-linux-gnu -mattr=avx2 --filetype=obj -o a.o

Error:

Unknown type!
UNREACHABLE executed at root/llvm/llvm/lib/CodeGen/ValueTypes.cpp:567!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ../../llvm/build/bin/llc -mtriple=x86_64-unknown-linux-gnu -mattr=avx2 --filetype=obj -o a.o
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@async_execute_fn'
 #0 0x00005635872d638f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../llvm/build/bin/llc+0x1d3a38f)
 #1 0x00005635872d3d54 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7013fa0420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f701399400b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007f7013973859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #5 0x000056358722779e (../../llvm/build/bin/llc+0x1c8b79e)
 #6 0x00005635867488ce (../../llvm/build/bin/llc+0x11ac8ce)
 #7 0x0000563586748949 llvm::EVT::getEVT(llvm::Type*, bool) (../../llvm/build/bin/llc+0x11ac949)
 #8 0x0000563585b285bb llvm::TargetLoweringBase::getValueType(llvm::DataLayout const&, llvm::Type*, bool) const (../../llvm/build/bin/llc+0x58c5bb)
 #9 0x00005635862738bf llvm::ComputeValueVTs(llvm::TargetLowering const&, llvm::DataLayout const&, llvm::Type*, llvm::SmallVectorImpl<llvm::EVT>&, llvm::SmallVectorImpl<unsigned long>*, unsigned long) (../../llvm/build/bin/llc+0xcd78bf)
#10 0x000056358700b34b llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&, unsigned int) (../../llvm/build/bin/llc+0x1a6f34b)
#11 0x0000563586fe9ddd llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (../../llvm/build/bin/llc+0x1a4dddd)
#12 0x0000563586ff4dd7 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (../../llvm/build/bin/llc+0x1a58dd7)
#13 0x0000563587028436 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (../../llvm/build/bin/llc+0x1a8c436)
#14 0x00005635870a8fe0 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, true>, bool&) (../../llvm/build/bin/llc+0x1b0cfe0)
#15 0x00005635870a9d68 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (../../llvm/build/bin/llc+0x1b0dd68)
#16 0x00005635870abcef llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#17 0x0000563585c90f50 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#18 0x000056358644826e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#19 0x00005635869c05a5 llvm::FPPassManager::runOnFunction(llvm::Function&) (../../llvm/build/bin/llc+0x14245a5)
#20 0x00005635869c07e9 llvm::FPPassManager::runOnModule(llvm::Module&) (../../llvm/build/bin/llc+0x14247e9)
#21 0x00005635869c1032 llvm::legacy::PassManagerImpl::run(llvm::Module&) (../../llvm/build/bin/llc+0x1425032)
#22 0x0000563585aecc03 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#23 0x0000563585a72572 main (../../llvm/build/bin/llc+0x4d6572)
#24 0x00007f7013975083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#25 0x0000563585ae3f9e _start (../../llvm/build/bin/llc+0x547f9e)
Aborted (core dumped)

Here is the LLVM IR generated for the same: https://gist.github.com/amanchhaparia/c101d381f8d144cee107836159d42177

llvmbot commented 1 year ago

@llvm/issue-subscribers-mlir