[PATCH] D29020: [ARM] Change TCReturn to tBL if tailcall optimization fails.

Sanne Wouda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 05:23:02 PST 2017


sanwou01 created this revision.
Herald added a subscriber: aemerson.

https://reviews.llvm.org/D29020

Files:
  lib/Target/ARM/Thumb1FrameLowering.cpp


Index: lib/Target/ARM/Thumb1FrameLowering.cpp
===================================================================
--- lib/Target/ARM/Thumb1FrameLowering.cpp
+++ lib/Target/ARM/Thumb1FrameLowering.cpp
@@ -866,6 +866,16 @@
         // ARMv4T requires BX, see emitEpilogue
         if (!STI.hasV5TOps())
           continue;
+        // Tailcall optimization failed; change TCRETURN to a tBL
+        if (MI->getOpcode() == ARM::TCRETURNdi ||
+            MI->getOpcode() == ARM::TCRETURNri) {
+          unsigned Opcode = MI->getOpcode() == ARM::TCRETURNdi
+                            ? ARM::tBL : ARM::tBLXr;
+          MachineInstrBuilder BL = BuildMI(MF, DL, TII.get(Opcode));
+          BL.add(predOps(ARMCC::AL));
+          BL.add(MI->getOperand(0));
+          MBB.insert(MI, &*BL);
+        }
         Reg = ARM::PC;
         (*MIB).setDesc(TII.get(ARM::tPOP_RET));
         if (MI != MBB.end())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29020.85363.patch
Type: text/x-patch
Size: 903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170123/b5cb868a/attachment.bin>


More information about the llvm-commits mailing list