aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/ARM/ARMFastISel.cpp
diff options
context:
space:
mode:
authorLogan Chien <tzuhsiang.chien@gmail.com>2013-08-22 12:08:04 +0000
committerLogan Chien <tzuhsiang.chien@gmail.com>2013-08-22 12:08:04 +0000
commit7ddda4704cdb24163591857e8d08614463cec335 (patch)
tree4f900dd865b4e1b2dd07d0639427890a5bf1fd65 /lib/Target/ARM/ARMFastISel.cpp
parenta5bd3937ab34d88fe87f25f9c7d1f059445234b8 (diff)
downloadexternal_llvm-7ddda4704cdb24163591857e8d08614463cec335.zip
external_llvm-7ddda4704cdb24163591857e8d08614463cec335.tar.gz
external_llvm-7ddda4704cdb24163591857e8d08614463cec335.tar.bz2
Fix ARM FastISel PIC function call.
The function call to external function should come with PLT relocation type if the PIC relocation model is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMFastISel.cpp')
-rw-r--r--lib/Target/ARM/ARMFastISel.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp
index f4aaf09..628b514 100644
--- a/lib/Target/ARM/ARMFastISel.cpp
+++ b/lib/Target/ARM/ARMFastISel.cpp
@@ -2460,15 +2460,22 @@ bool ARMFastISel::SelectCall(const Instruction *I,
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
DL, TII.get(CallOpc));
+ unsigned char OpFlags = 0;
+
+ // Add MO_PLT for global address or external symbol in the PIC relocation
+ // model.
+ if (Subtarget->isTargetELF() && TM.getRelocationModel() == Reloc::PIC_)
+ OpFlags = ARMII::MO_PLT;
+
// ARM calls don't take a predicate, but tBL / tBLX do.
if(isThumb2)
AddDefaultPred(MIB);
if (UseReg)
MIB.addReg(CalleeReg);
else if (!IntrMemName)
- MIB.addGlobalAddress(GV, 0, 0);
+ MIB.addGlobalAddress(GV, 0, OpFlags);
else
- MIB.addExternalSymbol(IntrMemName, 0);
+ MIB.addExternalSymbol(IntrMemName, OpFlags);
// Add implicit physical register uses to the call.
for (unsigned i = 0, e = RegArgs.size(); i != e; ++i)