[llvm-commits] [llvm] r99096 - in /llvm/trunk: lib/Target/ARM/ARMLoadStoreOptimizer.cpp test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll
Bob Wilson
bob.wilson at apple.com
Sat Mar 20 15:20:40 PDT 2010
Author: bwilson
Date: Sat Mar 20 17:20:40 2010
New Revision: 99096
URL: http://llvm.org/viewvc/llvm-project?rev=99096&view=rev
Log:
pr6652: Use LDM to restore PC to the return address on ARMv4.
Patch by John Tytgat!
Added:
llvm/trunk/test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=99096&r1=99095&r2=99096&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Sat Mar 20 17:20:40 2010
@@ -1155,19 +1155,24 @@
};
}
-/// MergeReturnIntoLDM - If this is a exit BB, try merging the return op
-/// (bx lr) into the preceeding stack restore so it directly restore the value
-/// of LR into pc.
-/// ldmfd sp!, {r7, lr}
+/// MergeReturnIntoLDM - If this is a exit BB, try merging the return ops
+/// ("bx lr" and "mov pc, lr") into the preceeding stack restore so it
+/// directly restore the value of LR into pc.
+/// ldmfd sp!, {..., lr}
/// bx lr
+/// or
+/// ldmfd sp!, {..., lr}
+/// mov pc, lr
/// =>
-/// ldmfd sp!, {r7, pc}
+/// ldmfd sp!, {..., pc}
bool ARMLoadStoreOpt::MergeReturnIntoLDM(MachineBasicBlock &MBB) {
if (MBB.empty()) return false;
MachineBasicBlock::iterator MBBI = prior(MBB.end());
if (MBBI != MBB.begin() &&
- (MBBI->getOpcode() == ARM::BX_RET || MBBI->getOpcode() == ARM::tBX_RET)) {
+ (MBBI->getOpcode() == ARM::BX_RET ||
+ MBBI->getOpcode() == ARM::tBX_RET ||
+ MBBI->getOpcode() == ARM::MOVPCLR)) {
MachineInstr *PrevMI = prior(MBBI);
if (PrevMI->getOpcode() == ARM::LDM_UPD ||
PrevMI->getOpcode() == ARM::t2LDM_UPD) {
Added: llvm/trunk/test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll?rev=99096&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/2010-03-18-ldm-rtrn.ll Sat Mar 20 17:20:40 2010
@@ -0,0 +1,13 @@
+; RUN: llc < %s -mtriple=armv4-unknown-eabi | FileCheck %s
+; RUN: llc < %s -mtriple=armv5-unknown-eabi | FileCheck %s
+; RUN: llc < %s -mtriple=armv6-unknown-eabi | FileCheck %s
+
+define i32 @bar(i32 %a) nounwind {
+entry:
+ %0 = tail call i32 @foo(i32 %a) nounwind ; <i32> [#uses=1]
+ %1 = add nsw i32 %0, 3 ; <i32> [#uses=1]
+; CHECK: ldmia sp!, {r11, pc}
+ ret i32 %1
+}
+
+declare i32 @foo(i32)
More information about the llvm-commits
mailing list