aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/MC/MCObjectFileInfo.cpp7
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp7
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp4
-rw-r--r--lib/Target/Mips/MipsAsmPrinter.cpp8
-rw-r--r--lib/Target/Mips/MipsISelLowering.cpp20
-rw-r--r--lib/Target/Mips/MipsNaClRewritePass.cpp2
6 files changed, 22 insertions, 26 deletions
diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp
index 1e2086e565..2e1a045569 100644
--- a/lib/MC/MCObjectFileInfo.cpp
+++ b/lib/MC/MCObjectFileInfo.cpp
@@ -610,16 +610,9 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
SectionKind::getDataRel());
}
-// @LOCALMOD-START
-// TODO(petarj): HACK! Find a better way to set ELF::EF_MIPS_PIC flag.
-// See also file lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp.
-Reloc::Model RelocModelOption = Reloc::Default;
-// @LOCALMOD-END
-
void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
CodeModel::Model cm,
MCContext &ctx) {
- RelocModelOption = relocm; // @LOCALMOD
RelocM = relocm;
CMModel = cm;
Ctx = &ctx;
diff --git a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index 6c080408dd..8c262c39cd 100644
--- a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -18,13 +18,6 @@
#include "llvm/Support/ErrorHandling.h"
#include <list>
-// @LOCALMOD-START
-// TODO(petarj): HACK! Find better way to set ELF::EF_MIPS_PIC flag.
-// See also file lib/MC/MCObjectFileInfo.cpp.
-#include "llvm/Support/CodeGen.h"
-extern llvm::Reloc::Model RelocModelOption;
-// @LOCALMOD-END
-
using namespace llvm;
namespace {
diff --git a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
index ea29621ae2..2e2f4b9612 100644
--- a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
+++ b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
@@ -134,8 +134,8 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
// @LOCALMOD-BEGIN
if (TheTriple.isOSNaCl()) {
- MCStreamer *Streamer = createELFStreamer(Ctx, MAB, _OS, _Emitter,
- RelaxAll, NoExecStack);
+ MCStreamer *Streamer = createMipsELFStreamer(Ctx, MAB, _OS, _Emitter,
+ RelaxAll, NoExecStack);
Streamer->EmitBundleAlignMode(4);
return Streamer;
} else {
diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp
index 464ac66ec8..61fb94d531 100644
--- a/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -67,14 +67,6 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) {
return;
}
- // @LOCALMOD-BEGIN:
- // Do any auto-generated pseudo lowerings.
- if (Subtarget->isTargetNaCl() &&
- emitPseudoExpansionLowering(OutStreamer, MI)) {
- return;
- }
- // @LOCALMOD-END
-
MachineBasicBlock::const_instr_iterator I = MI;
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp
index 9ff266969f..30409a2b3d 100644
--- a/lib/Target/Mips/MipsISelLowering.cpp
+++ b/lib/Target/Mips/MipsISelLowering.cpp
@@ -2313,7 +2313,25 @@ GetNaClThreadPointer(SelectionDAG &DAG, DebugLoc DL) const {
unsigned PtrSize = PtrVT.getSizeInBits();
IntegerType *PtrTy = Type::getIntNTy(*DAG.getContext(), PtrSize);
- SDValue TlsReadTp = DAG.getExternalSymbol("__nacl_read_tp", PtrVT);
+ // We must check whether the __nacl_read_tp is defined in the module because
+ // local and global pic functions are called differently. If the function
+ // is local the address is calculated with %got and %lo relocations.
+ // Otherwise, the address is calculated with %call16 relocation.
+ const Function *NaClReadTp = NULL;
+ const Module *M = DAG.getMachineFunction().getFunction()->getParent();
+ for (Module::const_iterator I = M->getFunctionList().begin(),
+ E = M->getFunctionList().end(); I != E; ++I) {
+ if (I->getName() == "__nacl_read_tp") {
+ NaClReadTp = I;
+ break;
+ }
+ }
+
+ SDValue TlsReadTp;
+ if (NaClReadTp == NULL)
+ TlsReadTp = DAG.getExternalSymbol("__nacl_read_tp", PtrVT);
+ else
+ TlsReadTp = DAG.getGlobalAddress(NaClReadTp, DL, PtrVT);
ArgListTy Args;
TargetLowering::CallLoweringInfo CLI(
diff --git a/lib/Target/Mips/MipsNaClRewritePass.cpp b/lib/Target/Mips/MipsNaClRewritePass.cpp
index d4407e835e..6ab95109e9 100644
--- a/lib/Target/Mips/MipsNaClRewritePass.cpp
+++ b/lib/Target/Mips/MipsNaClRewritePass.cpp
@@ -80,7 +80,7 @@ static bool IsIndirectJump(const MachineInstr &MI) {
}
static bool IsIndirectCall(const MachineInstr &MI) {
- return (MI.getOpcode() == Mips::JALR);
+ return (MI.getOpcode() == Mips::JALR) || (MI.getOpcode() == Mips::JALRPseudo);
}
static bool IsDirectCall(const MachineInstr &MI) {