[llvm-commits] [llvm] r146229 - in /llvm/trunk: lib/Target/Mips/MipsISelLowering.cpp test/CodeGen/Mips/indirectcall.ll
Akira Hatanaka
ahatanaka at mips.com
Thu Dec 8 17:45:12 PST 2011
Author: ahatanak
Date: Thu Dec 8 19:45:12 2011
New Revision: 146229
URL: http://llvm.org/viewvc/llvm-project?rev=146229&view=rev
Log:
jalr should use t9 ($25) for indirect calls regardless of the relocation model
specified.
Added:
llvm/trunk/test/CodeGen/Mips/indirectcall.ll
Modified:
llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=146229&r1=146228&r2=146229&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Thu Dec 8 19:45:12 2011
@@ -2338,7 +2338,7 @@
// node so that legalize doesn't hack it.
unsigned char OpFlag;
bool IsPICCall = (IsN64 || IsPIC); // true if calls are translated to jalr $25
- bool LoadSymAddr = false;
+ bool GlobalOrExternal = false;
SDValue CalleeLo;
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
@@ -2355,7 +2355,7 @@
getPointerTy(), 0, OpFlag);
}
- LoadSymAddr = true;
+ GlobalOrExternal = true;
}
else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
if (IsN64 || (!IsO32 && IsPIC))
@@ -2366,14 +2366,14 @@
OpFlag = MipsII::MO_GOT_CALL;
Callee = DAG.getTargetExternalSymbol(S->getSymbol(),
getPointerTy(), OpFlag);
- LoadSymAddr = true;
+ GlobalOrExternal = true;
}
SDValue InFlag;
// Create nodes that load address of callee and copy it to T9
if (IsPICCall) {
- if (LoadSymAddr) {
+ if (GlobalOrExternal) {
// Load callee address
Callee = DAG.getNode(MipsISD::WrapperPIC, dl, getPointerTy(), Callee);
SDValue LoadValue = DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(),
@@ -2387,7 +2387,11 @@
} else
Callee = LoadValue;
}
+ }
+ // T9 should contain the address of the callee function if
+ // -reloction-model=pic or it is an indirect call.
+ if (IsPICCall || !GlobalOrExternal) {
// copy to T9
unsigned T9Reg = IsN64 ? Mips::T9_64 : Mips::T9;
Chain = DAG.getCopyToReg(Chain, dl, T9Reg, Callee, SDValue(0, 0));
Added: llvm/trunk/test/CodeGen/Mips/indirectcall.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/indirectcall.ll?rev=146229&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/indirectcall.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/indirectcall.ll Thu Dec 8 19:45:12 2011
@@ -0,0 +1,8 @@
+; RUN: llc < %s -march=mipsel -relocation-model=static | FileCheck %s
+
+define void @foo0(void (i32)* nocapture %f1) nounwind {
+entry:
+; CHECK: jalr $25
+ tail call void %f1(i32 13) nounwind
+ ret void
+}
More information about the llvm-commits
mailing list