[PowerPC] `Bad machine code: Using an undefined physical register` with `sspstrong` + `pwr10`
@AditiRM is already working on this.
Since Aug 24, 2026.
- 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"
%heap.SafeAllocator.FormatMemory = type { { ptr, i64 }, i6, [7 x i8] }
%debug.FormatStackTrace = type { %debug.StackTrace, i2, [7 x i8] }
%debug.StackTrace = type { { ptr, i64 }, i64 }
; Function Attrs: sspstrong
define fastcc void @heap.SafeAllocator.deinitLargeAlloc() #0 {
Entry:
%0 = alloca { %heap.SafeAllocator.FormatMemory, %debug.FormatStackTrace }, align 8
%1 = getelementptr i8, ptr %0, i64 24
tail call fastcc void null(ptr null, ptr null, i64 0, i6 0, i64 0)
ret void
}
attributes #0 = { sspstrong "target-cpu"="pwr10" }
```
```console
❯ llc --version | head -n2
LLVM (http://llvm.org/):
LLVM version 22.1.4
❯ llc reduced.ll
# Machine code for function heap.SafeAllocator.deinitLargeAlloc: NoPHIs, TracksLiveness, TiedOpsRewritten, TracksDebugUserValues
Frame Objects:
fi#0: size=8, align=8, at location [SP]
fi#1: size=56, align=8, at location [SP]
save/restore points:
save points are empty
restore points are empty
bb.0.Entry:
successors: %bb.2(0x7ffff800), %bb.1(0x00000800); %bb.2(100.00%), %bb.1(0.00%)
%0:g8rc = LOAD_STACK_GUARD :: (dereferenceable invariant load (s64) from @__stack_chk_guard)
STD %0:g8rc, 0, %stack.0.StackGuardSlot :: (volatile store (s64) into %stack.0.StackGuardSlot)
%1:g8rc = LI8 0
MTCTR8 %1:g8rc, implicit-def $ctr8
%2:g8rc = LD 0, %stack.0.StackGuardSlot :: (volatile load (s64) from %stack.0.StackGuardSlot)
%3:g8rc = LOAD_STACK_GUARD :: (dereferenceable invariant load (s64) from @__stack_chk_guard)
%4:crrc = CMPLD %3:g8rc, %2:g8rc
BCC 68, %4:crrc, %bb.1
B %bb.2
bb.1.Entry:
; predecessors: %bb.0
ADJCALLSTACKDOWN 32, 0, implicit-def dead $r1, implicit $r1
BL8_NOTOC &__stack_chk_fail, , implicit-def dead $lr8, implicit $rm, implicit-def $r1
ADJCALLSTACKUP 32, 0, implicit-def dead $r1, implicit $r1
bb.2.Entry:
; predecessors: %bb.0
TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
# End machine code for function heap.SafeAllocator.deinitLargeAlloc.
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 4: implicit $x3
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 5: implicit killed $x4
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 6: implicit killed $x5
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 7: implicit killed $x6
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 8: implicit killed $x7
*** Bad machine code: Using an undefined physical register ***
- function: heap.SafeAllocator.deinitLargeAlloc
- basic block: %bb.2 Entry (0x579387395d98)
- instruction: TCRETURNri8 $ctr8, 0, , implicit $rm, implicit $x3, implicit killed $x4, implicit killed $x5, implicit killed $x6, implicit killed $x7, implicit killed $x12
- operand 9: implicit killed $x12
LLVM ERROR: Found 6 machine code errors.
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 reduced.ll
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'Greedy Register Allocator' on function '@heap.SafeAllocator.deinitLargeAlloc'
#0 0x0000756757a221ed llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:846:3
#1 0x0000756757a1f324 llvm::sys::RunSignalHandlers() /home/alexrp/Sources/llvm/llvm/lib/Support/Signals.cpp:108:20
#2 0x0000756757a1fb3c SignalHandler(int, siginfo_t*, void*) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:429:14
#3 0x0000756756245f60 (/lib/x86_64-linux-gnu/libc.so.6+0x45f60)
#4 0x00007567562a5fed __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007567562a5fed __pthread_kill_internal ./nptl/pthread_kill.c:89:10
#6 0x00007567562a5fed pthread_kill ./nptl/pthread_kill.c:100:10
#7 0x0000756756245e2e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x0000756756228888 internal_signal_block_all ./stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
#9 0x0000756756228888 __abort_lock_wrlock ./stdlib/abort.c:62:3
#10 0x0000756756228888 abort ./stdlib/abort.c:85:3
#11 0x00007567572b9721 std::mutex::lock() /usr/include/c++/15/bits/std_mutex.h:119:22
#12 0x00007567572b9721 std::lock_guard::lock_guard(std::mutex&) /usr/include/c++/15/bits/std_mutex.h:252:23
#13 0x00007567572b9721 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 0x00007567580ba3ec (/opt/llvm-22/bin/../lib/libLLVM.so.22.1+0x16ba3ec)
#15 0x00007567580ba49e getNumBuckets /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/DenseMap.h:823:43
#16 0x00007567580ba49e getNumBuckets /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/DenseMap.h:551:66
#17 0x00007567580ba49e destroyAll /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/DenseMap.h:398:22
#18 0x00007567580ba49e ~DenseMap /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/DenseMap.h:787:21
#19 0x00007567580ba49e (anonymous namespace)::MachineVerifier::~MachineVerifier() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineVerifier.cpp:102:8
#20 0x00007567580d103e llvm::MachineFunction::verify(llvm::Pass*, char const*, llvm::raw_ostream*, bool) const /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineVerifier.cpp:430:1
#21 0x0000756757ef2863 llvm::LiveRangeCalc::findReachingDefs(llvm::LiveRange&, llvm::MachineBasicBlock&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRangeCalc.cpp:225:13
#22 0x0000756757ef32de llvm::LiveRangeCalc::extend(llvm::LiveRange&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRangeCalc.cpp:103:3
#23 0x0000756757ef3d7d llvm::MachineRegisterInfo::getNextOperandForReg(llvm::MachineOperand const*) /home/alexrp/Sources/llvm/llvm/include/llvm/CodeGen/MachineRegisterInfo.h:130:5
#24 0x0000756757ef3d7d llvm::MachineRegisterInfo::defusechain_iterator::advance() /home/alexrp/Sources/llvm/llvm/include/llvm/CodeGen/MachineRegisterInfo.h:1075:32
#25 0x0000756757ef3d7d llvm::MachineRegisterInfo::defusechain_iterator::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/CodeGen/MachineRegisterInfo.h:1107:16
#26 0x0000756757ef3d7d llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::Register, llvm::LaneBitmask, llvm::LiveInterval*) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveIntervalCalc.cpp:145:56
#27 0x0000756757ed4d60 llvm::MCRegisterInfo::DiffListIterator::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/MC/MCRegisterInfo.h:227:24
#28 0x0000756757ed4d60 llvm::MCSuperRegIterator::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/MC/MCRegisterInfo.h:620:24
#29 0x0000756757ed4d60 llvm::LiveIntervals::computeRegUnitRange(llvm::LiveRange&, llvm::MCRegUnit) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveIntervals.cpp:338:58
#30 0x0000756757efcaf1 operator() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRegMatrix.cpp:181:47
#31 0x0000756757efcaf1 foreachUnit > /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRegMatrix.cpp:104:15
#32 0x0000756757efcaf1 llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRegMatrix.cpp:178:28
#33 0x0000756757efcc7f llvm::LiveRegMatrix::checkInterference(llvm::LiveInterval const&, llvm::MCRegister) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/LiveRegMatrix.cpp:204:3
#34 0x00007567581b13ed llvm::AllocationOrder::Iterator::operator*() const /home/alexrp/Sources/llvm/llvm/lib/CodeGen/AllocationOrder.h:58:7
#35 0x00007567581b13ed llvm::RAGreedy::tryAssign(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl&, llvm::SmallSet> const&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocGreedy.cpp:542:20
#36 0x00007567581b196e llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl&, llvm::SmallSet>&, llvm::SmallVector, 8u>&, unsigned int) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocGreedy.cpp:2613:3
#37 0x00007567581b443d llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocGreedy.cpp:2325:24
#38 0x0000756758188b86 llvm::RegAllocBase::allocatePhysRegs() /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocBase.cpp:117:5
#39 0x00007567581afc24 llvm::RAGreedy::run(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocGreedy.cpp:2945:21
#40 0x00007567581b0503 (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/RegAllocGreedy.cpp:289:1
#41 0x0000756757fab02a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:30
#42 0x0000756757bddb2a llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1398:40
#43 0x0000756757bddd35 llvm::ilist_detail::node_base_prevnext, true>::getNext() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#44 0x0000756757bddd35 llvm::ilist_node_impl>::getNext() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node.h:108:66
#45 0x0000756757bddd35 llvm::ilist_iterator, false, false>::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#46 0x0000756757bddd35 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1443:22
#47 0x0000756757bde5cf runOnModule /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1513:38
#48 0x0000756757bde5cf llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:531:55
#49 0x000057936bc4e9f5 compileModule(char**, llvm::SmallVectorImpl&, llvm::LLVMContext&, std::__cxx11::basic_string, std::allocator>&) /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:874:34
#50 0x000057936bc41f5c main /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:462:35
#51 0x000075675622a575 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#52 0x000075675622a628 call_init ./csu/../csu/libc-start.c:128:20
#53 0x000075675622a628 __libc_start_main ./csu/../csu/libc-start.c:347:5
#54 0x000057936bc42ce5 _start (/opt/llvm-22/bin/llc+0x15ce5)
```
No crash if either `sspstrong` or `"target-cpu"="pwr10"` are removed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.