llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

llc crashes on llvm.coro.suspend with "Do not know how to promote this operator's operand!"

Open amanchhaparia opened this issue 3 years ago • 3 comments

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

amanchhaparia avatar Jan 10 '23 17:01 amanchhaparia

@llvm/issue-subscribers-mlir

llvmbot avatar Jan 10 '23 17:01 llvmbot

I reduced this to a direct llc reproducer. Running llc on the LLVM IR below still crashes during X86 DAG->DAG Instruction Selection with "Do not know how to promote this operator's operand!".

declare i8 @llvm.coro.suspend(token, i1)

define void @f() {
entry:
  call i8 @llvm.coro.suspend(token poison, i1 false)
  ret void
}

Men-cotton avatar Mar 23 '26 07:03 Men-cotton

@llvm/issue-subscribers-backend-x86

Author: Aman Chhaparia (amanchhaparia)

I am trying to lower the following IR but getting the following error. IR: ```mlir 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 '&lt;stdin&gt;'.
2.      Running pass 'X86 DAG-&gt;DAG Instruction Selection' on function '@<!-- -->async_execute_fn'
 #<!-- -->0 0x00005635872d638f llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, 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&amp;, llvm::Type*, bool) const (../../llvm/build/bin/llc+0x58c5bb)
 #<!-- -->9 0x00005635862738bf llvm::ComputeValueVTs(llvm::TargetLowering const&amp;, llvm::DataLayout const&amp;, llvm::Type*, llvm::SmallVectorImpl&lt;llvm::EVT&gt;&amp;, llvm::SmallVectorImpl&lt;unsigned long&gt;*, unsigned long) (../../llvm/build/bin/llc+0xcd78bf)
#<!-- -->10 0x000056358700b34b llvm::SelectionDAGBuilder::visitTargetIntrinsic(llvm::CallInst const&amp;, unsigned int) (../../llvm/build/bin/llc+0x1a6f34b)
#<!-- -->11 0x0000563586fe9ddd llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&amp;, unsigned int) (../../llvm/build/bin/llc+0x1a4dddd)
#<!-- -->12 0x0000563586ff4dd7 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&amp;) (../../llvm/build/bin/llc+0x1a58dd7)
#<!-- -->13 0x0000563587028436 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&amp;) (../../llvm/build/bin/llc+0x1a8c436)
#<!-- -->14 0x00005635870a8fe0 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator&lt;llvm::ilist_detail::node_options&lt;llvm::Instruction, true, false, void&gt;, false, true&gt;, llvm::ilist_iterator&lt;llvm::ilist_detail::node_options&lt;llvm::Instruction, true, false, void&gt;, false, true&gt;, bool&amp;) (../../llvm/build/bin/llc+0x1b0cfe0)
#<!-- -->15 0x00005635870a9d68 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&amp;) (../../llvm/build/bin/llc+0x1b0dd68)
#<!-- -->16 0x00005635870abcef llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) (.part.0) SelectionDAGISel.cpp:0:0
#<!-- -->17 0x0000563585c90f50 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&amp;) X86ISelDAGToDAG.cpp:0:0
#<!-- -->18 0x000056358644826e llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->19 0x00005635869c05a5 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (../../llvm/build/bin/llc+0x14245a5)
#<!-- -->20 0x00005635869c07e9 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (../../llvm/build/bin/llc+0x14247e9)
#<!-- -->21 0x00005635869c1032 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (../../llvm/build/bin/llc+0x1425032)
#<!-- -->22 0x0000563585aecc03 compileModule(char**, llvm::LLVMContext&amp;) 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 avatar Mar 23 '26 07:03 llvmbot