[PowerPC] Crash on `@llvm.prefetch(p, 1, 0, 0)`
- 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-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64le-unknown-linux5.10.0-musl"
define fastcc i16 @"behavior.prefetch.test.@prefetch()"() {
Entry:
call void @llvm.prefetch.p0(ptr null, i32 1, i32 0, 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)) #0
attributes #0 = { 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: t4: ch = Prefetch<(store (s8) into `ptr null`)> t0, Constant:i64<0>, TargetConstant:i32<1>, TargetConstant:i32<0>, TargetConstant:i32<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 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@"behavior.prefetch.test.@prefetch()"'
#0 0x00007bcd894fa70c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:911:3
#1 0x00007bcd894f7684 llvm::sys::RunSignalHandlers() /home/alexrp/Sources/llvm/llvm/lib/Support/Signals.cpp:108:20
#2 0x00007bcd894f7f49 SignalHandler(int, siginfo_t*, void*) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:474:14
#3 0x00007bcd87e45cb0 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x45cb0)
#4 0x00007bcd87ea642c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007bcd87ea642c __pthread_kill_internal ./nptl/pthread_kill.c:89:10
#6 0x00007bcd87ea642c pthread_kill ./nptl/pthread_kill.c:100:10
#7 0x00007bcd87e45b7e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007bcd87e288ec internal_signal_block_all ./stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
#9 0x00007bcd87e288ec __abort_lock_wrlock ./stdlib/abort.c:62:3
#10 0x00007bcd87e288ec abort ./stdlib/abort.c:85:3
#11 0x00007bcd88e16dab std::mutex::lock() /usr/include/c++/15/bits/std_mutex.h:119:22
#12 0x00007bcd88e16dab std::lock_guard::lock_guard(std::mutex&) /usr/include/c++/15/bits/std_mutex.h:252:23
#13 0x00007bcd88e16dab 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 0x00007bcd8a18302b llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:4632:14
#15 0x00007bcd8a1894aa getHwModeVT /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:2767:38
#16 0x00007bcd8a1894aa 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 0x00007bcd8d7e1fee (anonymous namespace)::PPCDAGToDAGISel::Select(llvm::SDNode*) /home/alexrp/Sources/llvm/build-23/lib/Target/PowerPC/PPCGenDAGISel.inc:136613:19
#18 0x00007bcd8a187457 llvm::SmallVectorTemplateCommon::isSmall() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:148:39
#19 0x00007bcd8a187457 llvm::SmallVectorImpl::~SmallVectorImpl() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:622:23
#20 0x00007bcd8a187457 llvm::SmallVector::~SmallVector() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/SmallVector.h:1243:3
#21 0x00007bcd8a187457 llvm::SelectionDAGISel::DoInstructionSelection() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1384:5
#22 0x00007bcd8a193d15 llvm::TimeRegion::~TimeRegion() /home/alexrp/Sources/llvm/llvm/include/llvm/Support/Timer.h:167:9
#23 0x00007bcd8a193d15 llvm::NamedRegionTimer::~NamedRegionTimer() /home/alexrp/Sources/llvm/llvm/include/llvm/Support/Timer.h:175:8
#24 0x00007bcd8a193d15 llvm::SelectionDAGISel::CodeGenAndEmitDAG() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1153:3
#25 0x00007bcd8a198207 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1883:11
#26 0x00007bcd8a19935c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:647:22
#27 0x00007bcd8d7ea93c (anonymous namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:173:5
#28 0x00007bcd8a1922c1 llvm::OptLevelChanger::~OptLevelChanger() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:286:11
#29 0x00007bcd8a1922c1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:396:1
#30 0x00007bcd8a1922c1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:374:6
#31 0x00007bcd89ab3912 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:95:30
#32 0x00007bcd896d612e llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1416:40
#33 0x00007bcd896d65f5 llvm::ilist_detail::node_base_prevnext, true>::getNext() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#34 0x00007bcd896d65f5 llvm::ilist_node_impl>::getNext() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node.h:108:66
#35 0x00007bcd896d65f5 llvm::ilist_iterator, false, false>::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#36 0x00007bcd896d65f5 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1469:22
#37 0x00007bcd896d7023 runOnModule /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1561:38
#38 0x00007bcd896d7023 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:533:55
#39 0x00005f4d0cc8c6c2 compileModule(char**, llvm::SmallVectorImpl&, llvm::LLVMContext&, std::__cxx11::basic_string, std::allocator>&) /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:882:34
#40 0x00005f4d0cc7fc6c main /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:460:35
#41 0x00007bcd87e2a601 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:83:3
#42 0x00007bcd87e2a718 call_init ./csu/../csu/libc-start.c:128:20
#43 0x00007bcd87e2a718 __libc_start_main ./csu/../csu/libc-start.c:347:5
#44 0x00005f4d0cc807d5 _start (/opt/llvm-23/bin/llc+0x127d5)
```
Contributor guide
Research direction
Start by reproducing the failure with llc -O0 reduced.ll for the powerpc64le target. Read the PPCDAGToDAGISel::Select path in lib/Target/PowerPC/PPCISelDAGToDAG.cpp and the reported PowerPC DAG-to-DAG instruction-selection pass. Done means this IR no longer causes Cannot select or an llc crash, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100