Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BPF] Vector used across basic block causes assertion LHS.getValueType().isVector() == VT.isVector() && "Cannot compare scalars to vectors" to fail #58884

Closed
HazyFish opened this issue Nov 9, 2022 · 1 comment

Comments

@HazyFish
Copy link
Contributor

HazyFish commented Nov 9, 2022

Decription

In the following code, when a vector is used across basic block, assertion LHS.getValueType().isVector() == VT.isVector() && "Cannot compare scalars to vectors" failed when targeting bpf.

The problem does not exist when targeting x86_64 or aarch64.
The problem does not exist when the vector used in urem is in the same basic block.

Minimal Reproduction

https://godbolt.org/z/s9MeWe7dr

Code

define void @f(ptr %0) {
BB:
  %B = ashr <2 x i32> <i32 3, i32 3>, <i32 1, i32 1>
  br label %BB1

BB1:                                             ; preds = %BB
  %B1 = urem <2 x i32> %B, <i32 -1, i32 -1>
  store <2 x i32> %B1, <2 x i32>* %0
  ret void
}

Stack Trace

llc: /home/henry/aflplusplus-isel/llvm-project/llvm/include/llvm/CodeGen/SelectionDAG.h:1124: llvm::SDValue llvm::SelectionDAG::getSetCC(const llvm::SDLoc &, llvm::EVT, llvm::SDValue, llvm::SDValue, ISD::CondCode, llvm::SDValue, bool): Assertion `LHS.getValueType().isVector() == VT.isVector() && "Cannot compare scalars to vectors"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: ./llvm-project/build-debug/bin/llc -mtriple=bpf ./crash-reports/dagisel-bpf/1.ll
1.	Running pass 'Function Pass Manager' on module './crash-reports/dagisel-bpf/1.ll'.
2.	Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x00000000047ada8a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:569:11
 #1 0x00000000047adc3b PrintStackTraceSignalHandler(void*) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
 #2 0x00000000047ac286 llvm::sys::RunSignalHandlers() /home/henry/aflplusplus-isel/llvm-project/llvm/lib/Support/Signals.cpp:104:5
 #3 0x00000000047ae365 SignalHandler(int) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f7fa316a980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #5 0x00007f7fa205ae87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f7fa205c7f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007f7fa204c3fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
 #8 0x00007f7fa204c472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
 #9 0x000000000127cb1a llvm::SelectionDAG::getSetCC(llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::ISD::CondCode, llvm::SDValue, bool) /home/henry/aflplusplus-isel/llvm-project/llvm/include/llvm/CodeGen/SelectionDAG.h:1125:5
#10 0x00000000042c910a (anonymous namespace)::DAGCombiner::visitREM(llvm::SDNode*) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4588:30
#11 0x00000000042b9c0f (anonymous namespace)::DAGCombiner::visit(llvm::SDNode*) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1707:40
#12 0x00000000042b93a8 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1828:10
#13 0x00000000042b89b6 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1626:18
#14 0x00000000042b829f llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:25478:3
#15 0x000000000451175f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:772:3
#16 0x000000000451130d 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&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:688:1
#17 0x0000000004510dab llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1603:11
#18 0x000000000450e356 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:467:3
#19 0x0000000001c4f5d5 (anonymous namespace)::BPFDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp:58:5
#20 0x00000000035783e5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:8
#21 0x0000000003c55c66 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:23
#22 0x0000000003c5aa92 llvm::FPPassManager::runOnModule(llvm::Module&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:16
#23 0x0000000003c56539 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:23
#24 0x0000000003c560ad llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:16
#25 0x0000000003c5ad71 llvm::legacy::PassManager::run(llvm::Module&) /home/henry/aflplusplus-isel/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1672:3
#26 0x0000000000d38a5c compileModule(char**, llvm::LLVMContext&) /home/henry/aflplusplus-isel/llvm-project/llvm/tools/llc/llc.cpp:737:41
#27 0x0000000000d36e02 main /home/henry/aflplusplus-isel/llvm-project/llvm/tools/llc/llc.cpp:418:13
#28 0x00007f7fa203dc87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#29 0x0000000000d3660a _start (./llvm-project/build-debug/bin/llc+0xd3660a)
@uilnauyisDP
Copy link

uilnauyisDP commented Sep 28, 2023

The issue has been fixed in fe05a0a @DataCorrupted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants