[llvm] [PowerPC] Utilize `getReservedRegs` to find asm clobberable registers. (PR #99766)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 26 03:01:49 PDT 2024


================
@@ -441,14 +442,11 @@ BitVector PPCRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
 
 bool PPCRegisterInfo::isAsmClobberable(const MachineFunction &MF,
                                        MCRegister PhysReg) const {
-  // We cannot use getReservedRegs() to find the registers that are not asm
-  // clobberable because there are some reserved registers which can be
-  // clobbered by inline asm. For example, when LR is clobbered, the register is
-  // saved and restored. We will hardcode the registers that are not asm
-  // cloberable in this function.
-
-  // The stack pointer (R1/X1) is not clobberable by inline asm
-  return PhysReg != PPC::R1 && PhysReg != PPC::X1;
+  // The counter registers are always reserved, but they are asm clobberable.
+  if (PhysReg == PPC::CTR || PhysReg == PPC::CTR8)
+    return true;
----------------
chenzheng1030 wrote:

LR is the same. It can not be allocated, but it can be clobbered.

https://github.com/llvm/llvm-project/pull/99766


More information about the llvm-commits mailing list