[llvm-bugs] [Bug 39555] New: ppc32 always reserves r2

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 4 22:09:40 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39555

            Bug ID: 39555
           Summary: ppc32 always reserves r2
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: joel at jms.id.au
                CC: llvm-bugs at lists.llvm.org

The PowerPC 32-bit port always reserves r2:

lib/Target/PowerPC/PPCRegisterInfo.cpp:

  // The SVR4 ABI reserves r2 and r13
  if (Subtarget.isSVR4ABI()) {
    // We only reserve r2 if we need to use the TOC pointer. If we have no
    // explicit uses of the TOC pointer (meaning we're a leaf function with
    // no constant-pool loads, etc.) and we have no potential uses inside an
    // inline asm block, then we can treat r2 has an ordinary callee-saved
    // register.
    const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
    if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
      markSuperRegs(Reserved, PPC::R2);  // System-reserved register
    markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
  }

This is useful for eg. Linux kernel, but other programs many not need to
reserve r2 and could instead allow the compiler to use it.

In order to support this clang would need a -ffixed-r2 flag (similar to GCC)
that allows programs such Linux to reserve r2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181105/1f14dccb/attachment.html>


More information about the llvm-bugs mailing list