diff options
author | Petar Jovanovic <petar.jovanovic@rt-rk.com> | 2013-04-11 03:23:13 +0200 |
---|---|---|
committer | Petar Jovanovic <petar.jovanovic@rt-rk.com> | 2013-04-11 03:23:13 +0200 |
commit | 29d2ddad89f1124216210a1e3fc9a216ed83f01c (patch) | |
tree | 6d070af9cd9900179f443443a8123ad075c68c51 /lib/Target/Mips | |
parent | 4aa5c4891346e228e17c09dcb449d5fa0702d80b (diff) |
[MIPS] Fix LLVM issues with recent LLVM trunk merge
This change fixes some of the issues that came with recent merge with LLVM
trunk, and it removes some workarounds that are not needed anymore in the
code. In more details, it:
- removes hack to set ELF::EF_MIPS_PIC flag;
- checks whether __nacl_read_tp is defined in the module, as different
relocation(s) is used to calculate the address;
- marks Mips::JALRPseudo as indirect call in NaCl rewrite pass;
- fixes incorrect merge in MipsAsmPrinter.cpp and MipsMCTargetDesc.cpp.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=2275
TEST= run smoke tests
Review URL: https://codereview.chromium.org/13601014
Diffstat (limited to 'lib/Target/Mips')
-rw-r--r-- | lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 7 | ||||
-rw-r--r-- | lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp | 4 | ||||
-rw-r--r-- | lib/Target/Mips/MipsAsmPrinter.cpp | 8 | ||||
-rw-r--r-- | lib/Target/Mips/MipsISelLowering.cpp | 20 | ||||
-rw-r--r-- | lib/Target/Mips/MipsNaClRewritePass.cpp | 2 |
5 files changed, 22 insertions, 19 deletions
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) { |