[X86] Crash on `@llvm.prefetch(p, 0, 1, 0)` on `znver5`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```llvm
; ModuleID = 'reduced.bc'
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux7.0.0-gnu2.43.0"
define fastcc i16 @"behavior.prefetch.test.@prefetch()"(ptr %0) #0 {
Entry:
call void @llvm.prefetch.p0(ptr %0, i32 0, i32 1, i32 0)
ret i16 0
}
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @llvm.prefetch.p0(ptr readonly captures(none), i32 immarg range(i32 0, 2), i32 immarg range(i32 0, 4), i32 immarg range(i32 0, 2)) #1
attributes #0 = { "target-cpu"="znver5" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }
```
```console
❯ llc --version | head -n2
LLVM (http://llvm.org/):
LLVM version 23.1.0-rc3
❯ llc -O0 reduced.ll
LLVM ERROR: Cannot select: t5: ch = Prefetch<(load (s8) from %ir.0)> t0, t2, TargetConstant:i32<0>, TargetConstant:i32<1>, TargetConstant:i32<0>
t2: i64,ch = CopyFromReg t0, Register:i64 %0
In function: behavior.prefetch.test.@prefetch()
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: llc -O0 reduced.ll
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'X86 DAG->DAG Instruction Selection' on function '@"behavior.prefetch.test.@prefetch()"'
#0 0x00007fee06efa70c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:911:3
#1 0x00007fee06ef7684 llvm::sys::RunSignalHandlers() /home/alexrp/Sources/llvm/llvm/lib/Support/Signals.cpp:108:20
#2 0x00007fee06ef7f49 SignalHandler(int, siginfo_t*, void*) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:474:14
#3 0x00007fee05845cb0 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x45cb0)
#4 0x00007fee058a642c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007fee058a642c __pthread_kill_internal ./nptl/pthread_kill.c:89:10
#6 0x00007fee058a642c pthread_kill ./nptl/pthread_kill.c:100:10
#7 0x00007fee05845b7e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007fee058288ec internal_signal_block_all ./stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
#9 0x00007fee058288ec __abort_lock_wrlock ./stdlib/abort.c:62:3
#10 0x00007fee058288ec abort ./stdlib/abort.c:85:3
#11 0x00007fee06816dab std::mutex::lock() /usr/include/c++/15/bits/std_mutex.h:119:22
#12 0x00007fee06816dab std::lock_guard::lock_guard(std::mutex&) /usr/include/c++/15/bits/std_mutex.h:252:23
#13 0x00007fee06816dab llvm::install_bad_alloc_error_handler(void (*)(void*, char const*, bool), void*) (.cold) /home/alexrp/Sources/llvm/llvm/lib/Support/ErrorHandling.cpp:162:61
#14 0x00007fee07b8302b llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:4632:14
#15 0x00007fee07b894aa getHwModeVT /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:2767:38
#16 0x00007fee07b894aa llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int, unsigned char const*) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:3773:25
#17 0x00007fee0b9ec6ae (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) /home/alexrp/Sources/llvm/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:6857:1
#18 0x00007fee07b87457 llvm::SmallVectorTemplateCommon::isSmall() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:148:39
#19 0x00007fee07b87457 llvm::SmallVectorImpl::~SmallVectorImpl() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:622:23
#20 0x00007fee07b87457 llvm::SmallVector::~SmallVector() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:1243:3
#21 0x00007fee07b87457 llvm::SelectionDAGISel::DoInstructionSelection() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1384:5
#22 0x00007fee07b93d15 llvm::TimeRegion::~TimeRegion() /home/alexrp/Sources/llvm/llvm/include/llvm/Support/Timer.h:167:9
#23 0x00007fee07b93d15 llvm::NamedRegionTimer::~NamedRegionTimer() /home/alexrp/Sources/llvm/llvm/include/llvm/Support/Timer.h:175:8
#24 0x00007fee07b93d15 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1153:3
#25 0x00007fee07b98207 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1883:11
#26 0x00007fee07b9935c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:647:22
#27 0x00007fee07b922c1 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:286:11
#28 0x00007fee07b922c1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:396:1
#29 0x00007fee07b922c1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:374:6
#30 0x00007fee074b3912 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:95:30
#31 0x00007fee070d612e llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1416:40
#32 0x00007fee070d65f5 llvm::ilist_detail::node_base_prevnext, true>::getNext() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#33 0x00007fee070d65f5 llvm::ilist_node_impl>::getNext() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node.h:108:66
#34 0x00007fee070d65f5 llvm::ilist_iterator, false, false>::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#35 0x00007fee070d65f5 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1469:22
#36 0x00007fee070d7023 runOnModule /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1561:38
#37 0x00007fee070d7023 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:533:55
#38 0x0000570d554f66c2 compileModule(char**, llvm::SmallVectorImpl&, llvm::LLVMContext&, std::__cxx11::basic_string, std::allocator>&) /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:882:34
#39 0x0000570d554e9c6c main /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:460:35
#40 0x00007fee0582a601 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:83:3
#41 0x00007fee0582a718 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007fee0582a718 __libc_start_main ./csu/../csu/libc-start.c:347:5
#43 0x0000570d554ea7d5 _start (/opt/llvm-23/bin/llc+0x127d5)
```
Contributor guide
Research direction
Reproduce the failure with `llc -O0 reduced.ll`, then inspect the X86 DAG-to-DAG instruction-selection path shown at `lib/Target/X86/X86DAGToDAG.cpp:6857`. Done means this `@llvm.prefetch` input targeting `znver5` no longer causes `llc` to abort and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100