[llvm-bugs] [Bug 43077] New: Function epilog optimization does not work

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 21 07:59:33 PDT 2019


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

            Bug ID: 43077
           Summary: Function epilog optimization does not work
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: rainer.herbertz at segger.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org,
                    Ties.Stuij at arm.com

In the ARM backend, using Thumb instructions and optimization for size
the function tryFoldSPUpdateIntoPushPop() (ARMBaseInstrInfo.cpp)
should optimize function return code like:

  add   sp, #4
  pop   {r4, r5, r6, r7, pc}

into:

  pop   {r3, r4, r5, r6, r7, pc}

But this never works on functions returning non-void, because in the loop

  for (int i = MI->getNumOperands() - 1; i >= RegListIdx; --i) {
    MachineOperand &MO = MI->getOperand(i);
    RegList.push_back(MO);

    if (MO.isReg() && TRI->getEncodingValue(MO.getReg()) < FirstRegEnc)
      FirstRegEnc = TRI->getEncodingValue(MO.getReg());
  }

the operand list contains R0 (return value) at the end (implicit killed)
and the loop ends up with FirstRegEnc = 0, which prevents the optimization.

So the last two operands in the list should be ignored somehow ??

-- 
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/20190821/e4154bb7/attachment.html>


More information about the llvm-bugs mailing list