[llvm-commits] [llvm] r157336 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-call.ll
Chad Rosier
mcrosier at apple.com
Wed May 23 11:38:57 PDT 2012
Author: mcrosier
Date: Wed May 23 13:38:57 2012
New Revision: 157336
URL: http://llvm.org/viewvc/llvm-project?rev=157336&view=rev
Log:
[arm-fast-isel] Add support for non-global callee.
Patch by Jush Lu <jush.msn at gmail.com>.
Modified:
llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
llvm/trunk/test/CodeGen/ARM/fast-isel-call.ll
Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=157336&r1=157335&r2=157336&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Wed May 23 13:38:57 2012
@@ -2216,11 +2216,6 @@
// Can't handle inline asm.
if (isa<InlineAsm>(Callee)) return false;
- // Only handle global variable Callees.
- const GlobalValue *GV = dyn_cast<GlobalValue>(Callee);
- if (!GV)
- return false;
-
// Check the calling convention.
ImmutableCallSite CS(CI);
CallingConv::ID CC = CS.getCallingConv();
@@ -2313,18 +2308,33 @@
// Issue the call.
MachineInstrBuilder MIB;
+ const GlobalValue *GV = dyn_cast<GlobalValue>(Callee);
unsigned CallOpc = ARMSelectCallOp(GV);
+ unsigned CalleeReg = 0;
+
+ if (!GV){
+ CallOpc = isThumb2 ? ARM::tBLXr : ARM::BLX;
+ CalleeReg = getRegForValue(Callee);
+ if (CalleeReg == 0) return false;
+ }
+
// Explicitly adding the predicate here.
if(isThumb2) {
// Explicitly adding the predicate here.
MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(CallOpc)));
- if (!IntrMemName)
+ if (!GV)
+ MIB.addReg(CalleeReg);
+ else if (!IntrMemName)
MIB.addGlobalAddress(GV, 0, 0);
else
MIB.addExternalSymbol(IntrMemName, 0);
} else {
- if (!IntrMemName)
+ if (!GV)
+ MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
+ TII.get(CallOpc))
+ .addReg(CalleeReg));
+ else if (!IntrMemName)
// Explicitly adding the predicate here.
MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL,
TII.get(CallOpc))
Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-call.ll?rev=157336&r1=157335&r2=157336&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/fast-isel-call.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/fast-isel-call.ll Wed May 23 13:38:57 2012
@@ -126,3 +126,23 @@
}
declare i32 @bar(i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext, i8 zeroext)
+
+define i32 @bar0(i32 %i) nounwind {
+ ret i32 0
+}
+
+define void @foo3() uwtable {
+; ARM: movw r0, #0
+; ARM: movw r1, :lower16:_bar0
+; ARM: movt r1, :upper16:_bar0
+; ARM: blx r1
+; THUMB: movs r0, #0
+; THUMB: movw r1, :lower16:_bar0
+; THUMB: movt r1, :upper16:_bar0
+; THUMB: blx r1
+ %fptr = alloca i32 (i32)*, align 8
+ store i32 (i32)* @bar0, i32 (i32)** %fptr, align 8
+ %1 = load i32 (i32)** %fptr, align 8
+ %call = call i32 %1(i32 0)
+ ret void
+}
More information about the llvm-commits
mailing list