Skip to content

[PowerPC] Impossible reg-to-reg copy when inline asm uses crN registers as inputs #196085

@alexrp

Description

@alexrp
; ModuleID = 'reduced.bc'
target datalayout = "E-m:e-p:32:32-Fn32-i64:64-n32"
target triple = "powerpc-unknown-unknown-eabi"

define i32 @repro.sysret() {
Entry:
  %0 = call i32 asm sideeffect "rfi", "={r3},{r3},{cr0}"(i32 0, i1 false)
  ret i32 %0
}
❯ llc --version | head -n2
LLVM (http://llvm.org/):
  LLVM version 22.1.4
❯ llc reduced.ll
Impossible reg-to-reg copy
UNREACHABLE executed at /home/alexrp/Sources/llvm/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1910!
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 'Post-RA pseudo instruction expansion pass' on function '@repro.sysret'
 #0 0x000075d2d0c221ed llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:846:3
 #1 0x000075d2d0c1f324 llvm::sys::RunSignalHandlers() /home/alexrp/Sources/llvm/llvm/lib/Support/Signals.cpp:108:20
 #2 0x000075d2d0c1fb3c SignalHandler(int, siginfo_t*, void*) /home/alexrp/Sources/llvm/llvm/lib/Support/Unix/Signals.inc:429:14
 #3 0x000075d2cf445f60 (/lib/x86_64-linux-gnu/libc.so.6+0x45f60)
 #4 0x000075d2cf4a5fed __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x000075d2cf4a5fed __pthread_kill_internal ./nptl/pthread_kill.c:89:10
 #6 0x000075d2cf4a5fed pthread_kill ./nptl/pthread_kill.c:100:10
 #7 0x000075d2cf445e2e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x000075d2cf428888 internal_signal_block_all ./stdlib/../sysdeps/unix/sysv/linux/internal-signals.h:81:3
 #9 0x000075d2cf428888 __abort_lock_wrlock ./stdlib/abort.c:62:3
#10 0x000075d2cf428888 abort ./stdlib/abort.c:85:3
#11 0x000075d2d0b296be (/opt/llvm-22/bin/../lib/libLLVM.so.22.1+0xf296be)
#12 0x000075d2d4c7e7a0 llvm::PPCInstrInfo::copyPhysReg(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::DebugLoc const&, llvm::Register, llvm::Register, bool, bool, bool) const /home/alexrp/Sources/llvm/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp:1869:43
#13 0x000075d2d14a9358 llvm::MachineInstr::getNumOperands() const /home/alexrp/Sources/llvm/llvm/include/llvm/CodeGen/MachineInstr.h:602:44
#14 0x000075d2d14a9358 llvm::TargetInstrInfo::lowerCopy(llvm::MachineInstr*, llvm::TargetRegisterInfo const*) const /home/alexrp/Sources/llvm/llvm/lib/CodeGen/TargetInstrInfo.cpp:904:25
#15 0x000075d2d104cfb8 (anonymous namespace)::ExpandPostRA::run(llvm::MachineFunction&) (.constprop.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:161:20
#16 0x000075d2d104d888 (anonymous namespace)::ExpandPostRALegacy::runOnMachineFunction(llvm::MachineFunction&) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/ExpandPostRAPseudos.cpp:139:1
#17 0x000075d2d11ab02a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) /home/alexrp/Sources/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:30
#18 0x000075d2d0dddb2a llvm::FPPassManager::runOnFunction(llvm::Function&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1398:40
#19 0x000075d2d0dddd35 llvm::ilist_detail::node_base_prevnext<llvm::ilist_node_base<true, void>, true>::getNext() const /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node_base.h:42:38
#20 0x000075d2d0dddd35 llvm::ilist_node_impl<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>>::getNext() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_node.h:108:66
#21 0x000075d2d0dddd35 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Function, true, false, void, false, void>, false, false>::operator++() /home/alexrp/Sources/llvm/llvm/include/llvm/ADT/ilist_iterator.h:187:25
#22 0x000075d2d0dddd35 llvm::FPPassManager::runOnModule(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1443:22
#23 0x000075d2d0dde5cf runOnModule /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:1513:38
#24 0x000075d2d0dde5cf llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/alexrp/Sources/llvm/llvm/lib/IR/LegacyPassManager.cpp:531:55
#25 0x00006544af5df9f5 compileModule(char**, llvm::SmallVectorImpl<llvm::PassPlugin>&, llvm::LLVMContext&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:874:34
#26 0x00006544af5d2f5c main /home/alexrp/Sources/llvm/llvm/tools/llc/llc.cpp:462:35
#27 0x000075d2cf42a575 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#28 0x000075d2cf42a628 call_init ./csu/../csu/libc-start.c:128:20
#29 0x000075d2cf42a628 __libc_start_main ./csu/../csu/libc-start.c:347:5
#30 0x00006544af5d3ce5 _start (/opt/llvm-22/bin/llc+0x15ce5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions