aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/Passes.cpp10
-rw-r--r--lib/Linker/LinkArchives.cpp213
-rw-r--r--lib/Linker/LinkItems.cpp242
-rw-r--r--lib/MC/MCObjectStreamer.cpp3
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.cpp6
-rw-r--r--lib/Target/ARM/ARMSubtarget.cpp2
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp17
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp11
-rw-r--r--lib/Target/Mips/MipsAsmPrinter.cpp15
-rw-r--r--lib/Target/Mips/MipsDelaySlotFiller.cpp30
-rw-r--r--lib/Target/Mips/MipsISelDAGToDAG.cpp12
-rw-r--r--lib/Target/Mips/MipsInstrFPU.td8
-rw-r--r--lib/Target/Mips/MipsMCInstLower.cpp1
-rw-r--r--lib/Target/Mips/MipsNaClRewritePass.cpp1
-rw-r--r--lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp9
-rw-r--r--lib/Target/X86/X86FastISel.cpp69
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp42
-rw-r--r--lib/Target/X86/X86InstrArithmetic.td1
-rw-r--r--lib/Target/X86/X86InstrInfo.td10
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp12
-rw-r--r--lib/Transforms/NaCl/ExpandTls.cpp5
-rw-r--r--lib/Transforms/Scalar/NaClCcRewrite.cpp1053
22 files changed, 146 insertions, 1626 deletions
diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp
index f8e390c753..b79f9f9816 100644
--- a/lib/CodeGen/Passes.cpp
+++ b/lib/CodeGen/Passes.cpp
@@ -352,16 +352,6 @@ void TargetPassConfig::addIRPasses() {
addPass(createTypeBasedAliasAnalysisPass());
addPass(createBasicAliasAnalysisPass());
- // @LOCALMOD-START
- addPass(createNaClCcRewritePass(TM->getTargetLowering()));
- // TODO: consider adding a cleanup pass, e.g. constant propagation
- // Note: we run this before the verfier step because it may cause
- // a *temporary* inconsistency:
- // A function may have been rewritting before we are rewriting
- // its callers - which would lead to a parameter mismatch complaint
- // from the verifier.
- // @LOCALMOD-END
-
// Before running any passes, run the verifier to determine if the input
// coming from the front-end and/or optimizer is valid.
if (!DisableVerify)
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp
deleted file mode 100644
index e5ec0b83b8..0000000000
--- a/lib/Linker/LinkArchives.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-//===- lib/Linker/LinkArchives.cpp - Link LLVM objects and libraries ------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains routines to handle linking together LLVM bitcode files,
-// and to handle annoying things like static libraries.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Linker.h"
-#include "llvm/ADT/SetOperations.h"
-#include "llvm/Bitcode/Archive.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/CommandLine.h" // @LOCALMOD
-
-#include <memory>
-#include <set>
-using namespace llvm;
-
-// @LOCALMOD-START
-// NOTE: this has a similar effect as
-// tools/llvm/llvm-preserve.ll
-// which in turn is similar to the GNUS's attribute((used))
-// TODO(robertm): This is a little hackish for now
-static cl::list<std::string>
-UndefList("referenced-list", cl::value_desc("list"),
- cl::desc("A list of symbols assumed to be referenced externally"),
- cl::CommaSeparated);
-// @LOCALMOD-END
-
-/// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
-/// exist in an LLVM module. This is a bit tricky because there may be two
-/// symbols with the same name but different LLVM types that will be resolved to
-/// each other but aren't currently (thus we need to treat it as resolved).
-///
-/// Inputs:
-/// M - The module in which to find undefined symbols.
-///
-/// Outputs:
-/// UndefinedSymbols - A set of C++ strings containing the name of all
-/// undefined symbols.
-///
-static void
-GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
- std::set<std::string> DefinedSymbols;
- UndefinedSymbols.clear();
- // @LOCALMOD-START
- UndefinedSymbols.insert(UndefList.begin(), UndefList.end());
- // @LOCALMOD-END
-
- // If the program doesn't define a main, try pulling one in from a .a file.
- // This is needed for programs where the main function is defined in an
- // archive, such f2c'd programs.
- Function *Main = M->getFunction("main");
- if (Main == 0 || Main->isDeclaration())
- UndefinedSymbols.insert("main");
-
- for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
- if (I->hasName()) {
- if (I->isDeclaration())
- UndefinedSymbols.insert(I->getName());
- else if (!I->hasLocalLinkage()) {
- assert(!I->hasDLLImportLinkage()
- && "Found dllimported non-external symbol!");
- DefinedSymbols.insert(I->getName());
- }
- }
-
- for (Module::global_iterator I = M->global_begin(), E = M->global_end();
- I != E; ++I)
- if (I->hasName()) {
- if (I->isDeclaration())
- UndefinedSymbols.insert(I->getName());
- else if (!I->hasLocalLinkage()) {
- assert(!I->hasDLLImportLinkage()
- && "Found dllimported non-external symbol!");
- DefinedSymbols.insert(I->getName());
- }
- }
-
- for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
- I != E; ++I)
- if (I->hasName())
- DefinedSymbols.insert(I->getName());
-
- // Prune out any defined symbols from the undefined symbols set...
- for (std::set<std::string>::iterator I = UndefinedSymbols.begin();
- I != UndefinedSymbols.end(); )
- if (DefinedSymbols.count(*I))
- UndefinedSymbols.erase(I++); // This symbol really is defined!
- else
- ++I; // Keep this symbol in the undefined symbols list
-}
-
-/// LinkInArchive - opens an archive library and link in all objects which
-/// provide symbols that are currently undefined.
-///
-/// Inputs:
-/// Filename - The pathname of the archive.
-///
-/// Return Value:
-/// TRUE - An error occurred.
-/// FALSE - No errors.
-bool
-Linker::LinkInArchive(const sys::Path &Filename, bool &is_native) {
- // Make sure this is an archive file we're dealing with
- if (!Filename.isArchive())
- return error("File '" + Filename.str() + "' is not an archive.");
-
- // Open the archive file
- verbose("Linking archive file '" + Filename.str() + "'");
-
- // Find all of the symbols currently undefined in the bitcode program.
- // If all the symbols are defined, the program is complete, and there is
- // no reason to link in any archive files.
- std::set<std::string> UndefinedSymbols;
- GetAllUndefinedSymbols(Composite, UndefinedSymbols);
-
- if (UndefinedSymbols.empty()) {
- verbose("No symbols undefined, skipping library '" + Filename.str() + "'");
- return false; // No need to link anything in!
- }
-
- std::string ErrMsg;
- std::auto_ptr<Archive> AutoArch (
- Archive::OpenAndLoadSymbols(Filename, Context, &ErrMsg));
-
- Archive* arch = AutoArch.get();
-
- if (!arch)
- return error("Cannot read archive '" + Filename.str() +
- "': " + ErrMsg);
- if (!arch->isBitcodeArchive()) {
- is_native = true;
- return false;
- }
- is_native = false;
-
- // Save a set of symbols that are not defined by the archive. Since we're
- // entering a loop, there's no point searching for these multiple times. This
- // variable is used to "set_subtract" from the set of undefined symbols.
- std::set<std::string> NotDefinedByArchive;
-
- // Save the current set of undefined symbols, because we may have to make
- // multiple passes over the archive:
- std::set<std::string> CurrentlyUndefinedSymbols;
-
- do {
- CurrentlyUndefinedSymbols = UndefinedSymbols;
-
- // Find the modules we need to link into the target module. Note that arch
- // keeps ownership of these modules and may return the same Module* from a
- // subsequent call.
- SmallVector<Module*, 16> Modules;
- if (!arch->findModulesDefiningSymbols(UndefinedSymbols, Modules, &ErrMsg))
- return error("Cannot find symbols in '" + Filename.str() +
- "': " + ErrMsg);
-
- // If we didn't find any more modules to link this time, we are done
- // searching this archive.
- if (Modules.empty())
- break;
-
- // Any symbols remaining in UndefinedSymbols after
- // findModulesDefiningSymbols are ones that the archive does not define. So
- // we add them to the NotDefinedByArchive variable now.
- NotDefinedByArchive.insert(UndefinedSymbols.begin(),
- UndefinedSymbols.end());
-
- // Loop over all the Modules that we got back from the archive
- for (SmallVectorImpl<Module*>::iterator I=Modules.begin(), E=Modules.end();
- I != E; ++I) {
-
- // Get the module we must link in.
- std::string moduleErrorMsg;
- Module* aModule = *I;
- if (aModule != NULL) {
- if (aModule->MaterializeAll(&moduleErrorMsg))
- return error("Could not load a module: " + moduleErrorMsg);
-
- verbose(" Linking in module: " + aModule->getModuleIdentifier());
-
- // Link it in
- if (LinkInModule(aModule, &moduleErrorMsg))
- return error("Cannot link in module '" +
- aModule->getModuleIdentifier() + "': " + moduleErrorMsg);
- }
- }
-
- // Get the undefined symbols from the aggregate module. This recomputes the
- // symbols we still need after the new modules have been linked in.
- GetAllUndefinedSymbols(Composite, UndefinedSymbols);
-
- // At this point we have two sets of undefined symbols: UndefinedSymbols
- // which holds the undefined symbols from all the modules, and
- // NotDefinedByArchive which holds symbols we know the archive doesn't
- // define. There's no point searching for symbols that we won't find in the
- // archive so we subtract these sets.
- set_subtract(UndefinedSymbols, NotDefinedByArchive);
-
- // If there's no symbols left, no point in continuing to search the
- // archive.
- if (UndefinedSymbols.empty())
- break;
- } while (CurrentlyUndefinedSymbols != UndefinedSymbols);
-
- return false;
-}
diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp
deleted file mode 100644
index 0ab551d14d..0000000000
--- a/lib/Linker/LinkItems.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-//===- lib/Linker/LinkItems.cpp - Link LLVM objects and libraries ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains routines to handle linking together LLVM bitcode files,
-// and to handle annoying things like static libraries.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Linker.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/IR/Module.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Support/system_error.h"
-using namespace llvm;
-
-// LinkItems - This function is the main entry point into linking. It takes a
-// list of LinkItem which indicates the order the files should be linked and
-// how each file should be treated (plain file or with library search). The
-// function only links bitcode and produces a result list of items that are
-// native objects.
-bool
-Linker::LinkInItems(const ItemList& Items, ItemList& NativeItems) {
- // Clear the NativeItems just in case
- NativeItems.clear();
-
- // For each linkage item ...
- for (ItemList::const_iterator I = Items.begin(), E = Items.end();
- I != E; ++I) {
- if (I->second) {
- // Link in the library suggested.
- bool is_native = false;
- if (LinkInLibrary(I->first, is_native))
- return true;
- if (is_native)
- NativeItems.push_back(*I);
- } else {
- // Link in the file suggested
- bool is_native = false;
- if (LinkInFile(sys::Path(I->first), is_native))
- return true;
- if (is_native)
- NativeItems.push_back(*I);
- }
- }
-
- // @LOCALMOD-BEGIN
- // At this point we have processed all the link items provided to us. Since
- // we have an aggregated module at this point, the dependent libraries in
- // that module should also be aggregated with duplicates eliminated. This is
- // now the time to process the dependent libraries to resolve any remaining
- // symbols.
- bool is_native;
- for (Module::lib_iterator I = Composite->lib_begin(),
- E = Composite->lib_end(); I != E; ++I) {
- if(LinkInLibrary(*I, is_native))
- return true;
- if (is_native)
- NativeItems.push_back(std::make_pair(*I, true));
- }
- // @LOCALMOD-END
- return false;
-}
-
-
-/// LinkInLibrary - links one library into the HeadModule.
-///
-bool Linker::LinkInLibrary(StringRef Lib, bool& is_native) {
- is_native = false;
- // Determine where this library lives.
- sys::Path Pathname = FindLib(Lib);
- if (Pathname.isEmpty())
- return error("Cannot find library '" + Lib.str() + "'");
-
- // If its an archive, try to link it in
- std::string Magic;
- Pathname.getMagicNumber(Magic, 64);
- switch (sys::IdentifyFileType(Magic.c_str(), 64)) {
- default: llvm_unreachable("Bad file type identification");
- case sys::Unknown_FileType:
- return warning("Supposed library '" + Lib.str() + "' isn't a library.");
-
- case sys::Bitcode_FileType:
- // LLVM ".so" file.
- if (LinkInFile(Pathname, is_native))
- return true;
- break;
-
- case sys::Archive_FileType:
- if (LinkInArchive(Pathname, is_native))
- return error("Cannot link archive '" + Pathname.str() + "'");
- break;
-
- case sys::ELF_Relocatable_FileType:
- case sys::ELF_SharedObject_FileType:
- case sys::Mach_O_Object_FileType:
- case sys::Mach_O_FixedVirtualMemorySharedLib_FileType:
- case sys::Mach_O_DynamicallyLinkedSharedLib_FileType:
- case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType:
- case sys::COFF_FileType:
- is_native = true;
- break;
- }
- return false;
-}
-
-/// LinkLibraries - takes the specified library files and links them into the
-/// main bitcode object file.
-///
-/// Inputs:
-/// Libraries - The list of libraries to link into the module.
-///
-/// Return value:
-/// FALSE - No error.
-/// TRUE - Error.
-///
-bool Linker::LinkInLibraries(const std::vector<std::string> &Libraries) {
-
- // Process the set of libraries we've been provided.
- bool is_native = false;
- for (unsigned i = 0; i < Libraries.size(); ++i)
- if (LinkInLibrary(Libraries[i], is_native))
- return true;
- // @LOCALMOD-BEGIN
- // At this point we have processed all the libraries provided to us. Since
- // we have an aggregated module at this point, the dependent libraries in
- // that module should also be aggregated with duplicates eliminated. This is
- // now the time to process the dependent libraries to resolve any remaining
- // symbols.
- const Module::LibraryListType& DepLibs = Composite->getLibraries();
- for (Module::LibraryListType::const_iterator I = DepLibs.begin(),
- E = DepLibs.end(); I != E; ++I)
- if (LinkInLibrary(*I, is_native))
- return true;
- // @LOCALMOD-END
- return false;
-}
-
-/// LinkInFile - opens a bitcode file and links in all objects which
-/// provide symbols that are currently undefined.
-///
-/// Inputs:
-/// File - The pathname of the bitcode file.
-///
-/// Outputs:
-/// ErrorMessage - A C++ string detailing what error occurred, if any.
-///
-/// Return Value:
-/// TRUE - An error occurred.
-/// FALSE - No errors.
-///
-bool Linker::LinkInFile(const sys::Path &File, bool &is_native) {
- is_native = false;
-
- // Check for a file of name "-", which means "read standard input"
- if (File.str() == "-") {
- std::auto_ptr<Module> M;
- OwningPtr<MemoryBuffer> Buffer;
- error_code ec;
- if (!(ec = MemoryBuffer::getSTDIN(Buffer))) {
- if (!Buffer->getBufferSize()) {
- Error = "standard input is empty";
- } else {
- M.reset(ParseBitcodeFile(Buffer.get(), Context, &Error));
- if (M.get())
- if (!LinkInModule(M.get(), &Error))
- return false;
- }
- }
- return error("Cannot link stdin: " + ec.message());
- }
-
- // Determine what variety of file it is.
- std::string Magic;
- if (!File.getMagicNumber(Magic, 64))
- return error("Cannot find linker input '" + File.str() + "'");
-
- switch (sys::IdentifyFileType(Magic.c_str(), 64)) {
- default: llvm_unreachable("Bad file type identification");
- case sys::Unknown_FileType:
- return warning("Ignoring file '" + File.str() +
- "' because does not contain bitcode.");
-
- case sys::Archive_FileType:
- // A user may specify an ar archive without -l, perhaps because it
- // is not installed as a library. Detect that and link the archive.
- if (LinkInArchive(File, is_native))
- return true;
- break;
-
- case sys::Bitcode_FileType: {
- verbose("Linking bitcode file '" + File.str() + "'");
- std::auto_ptr<Module> M(LoadObject(File));
- if (M.get() == 0)
- return error("Cannot load file '" + File.str() + "': " + Error);
- if (LinkInModule(M.get(), &Error))
- return error("Cannot link file '" + File.str() + "': " + Error);
-
- verbose("Linked in file '" + File.str() + "'");
- break;
- }
-
- case sys::ELF_Relocatable_FileType:
- case sys::ELF_SharedObject_FileType:
- case sys::Mach_O_Object_FileType:
- case sys::Mach_O_FixedVirtualMemorySharedLib_FileType:
- case sys::Mach_O_DynamicallyLinkedSharedLib_FileType:
- case sys::Mach_O_DynamicallyLinkedSharedLibStub_FileType:
- case sys::COFF_FileType:
- is_native = true;
- break;
- }
- return false;
-}
-
-/// LinkFiles - takes a module and a list of files and links them all together.
-/// It locates the file either in the current directory, as its absolute
-/// or relative pathname, or as a file somewhere in LLVM_LIB_SEARCH_PATH.
-///
-/// Inputs:
-/// Files - A vector of sys::Path indicating the LLVM bitcode filenames
-/// to be linked. The names can refer to a mixture of pure LLVM
-/// bitcode files and archive (ar) formatted files.
-///
-/// Return value:
-/// FALSE - No errors.
-/// TRUE - Some error occurred.
-///
-bool Linker::LinkInFiles(const std::vector<sys::Path> &Files) {
- bool is_native;
- for (unsigned i = 0; i < Files.size(); ++i)
- if (LinkInFile(Files[i], is_native))
- return true;
- return false;
-}
diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp
index e835eea7df..1dff3f2977 100644
--- a/lib/MC/MCObjectStreamer.cpp
+++ b/lib/MC/MCObjectStreamer.cpp
@@ -176,7 +176,8 @@ void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
// @LOCALMOD-BEGIN
- if (getAssembler().getBackend().CustomExpandInst(Inst, *this)) {
+ if (getAssembler().isBundlingEnabled() &&
+ getAssembler().getBackend().CustomExpandInst(Inst, *this)) {
return;
}
// @LOCALMOD-END
diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
index 65b334bac4..c48df8a96f 100644
--- a/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -1824,10 +1824,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Non-Darwin binutils don't yet support the "trap" mnemonic.
// FIXME: Remove this special case when they do.
if (!Subtarget->isTargetDarwin()) {
- // @LOCALMOD-START
- //.long 0xe7fedef0 @ trap
- uint32_t Val = 0xe7fedef0UL;
- // @LOCALMOD-END
+ //.long 0xe7ffdefe @ trap
+ uint32_t Val = 0xe7ffdefeUL;
OutStreamer.AddComment("trap");
OutStreamer.EmitIntValue(Val, 4);
return;
diff --git a/lib/Target/ARM/ARMSubtarget.cpp b/lib/Target/ARM/ARMSubtarget.cpp
index 1e54c3bb74..0501ee4c1d 100644
--- a/lib/Target/ARM/ARMSubtarget.cpp
+++ b/lib/Target/ARM/ARMSubtarget.cpp
@@ -74,7 +74,7 @@ void ARMSubtarget::initializeEnvironment() {
HasVFPv4 = false;
HasNEON = false;
UseNEONForSinglePrecisionFP = false;
- UseInlineJumpTables(!NoInlineJumpTables);
+ UseInlineJumpTables = !NoInlineJumpTables;
UseMulOps = UseFusedMulOps;
SlowFPVMLx = false;
HasVMLxForwarding = false;
diff --git a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index c39d3fad3b..6c080408dd 100644
--- a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -49,7 +49,6 @@ namespace {
virtual unsigned GetRelocType(const MCValue &Target, const MCFixup &Fixup,
bool IsPCRel, bool IsRelocWithSymbol,
int64_t Addend) const;
- virtual unsigned getEFlags() const;
virtual const MCSymbol *ExplicitRelSym(const MCAssembler &Asm,
const MCValue &Target,
const MCFragment &F,
@@ -68,22 +67,6 @@ MipsELFObjectWriter::MipsELFObjectWriter(bool _is64Bit, uint8_t OSABI,
MipsELFObjectWriter::~MipsELFObjectWriter() {}
-// FIXME: get the real EABI Version from the Subtarget class.
-unsigned MipsELFObjectWriter::getEFlags() const {
-
- // FIXME: We can't tell if we are PIC (dynamic) or CPIC (static)
- unsigned Flag = ELF::EF_MIPS_NOREORDER;
-
- if (is64Bit())
- Flag |= ELF::EF_MIPS_ARCH_64R2;
- else
- Flag |= ELF::EF_MIPS_ARCH_32R2;
- /* @LOCLAMOD-START */
- if (RelocModelOption == Reloc::PIC_ || RelocModelOption == Reloc::Default)
- Flag |= ELF::EF_MIPS_PIC;
- /* @LOCLAMOD-END */
- return Flag;
-}
const MCSymbol *MipsELFObjectWriter::ExplicitRelSym(const MCAssembler &Asm,
const MCValue &Target,
diff --git a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
index c77be4f743..ea29621ae2 100644
--- a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
+++ b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
@@ -133,11 +133,14 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
Triple TheTriple(TT);
// @LOCALMOD-BEGIN
- MCStreamer *Streamer = createELFStreamer(Ctx, MAB, _OS, _Emitter,
- RelaxAll, NoExecStack);
- if (TheTriple.isOSNaCl())
+ if (TheTriple.isOSNaCl()) {
+ MCStreamer *Streamer = createELFStreamer(Ctx, MAB, _OS, _Emitter,
+ RelaxAll, NoExecStack);
Streamer->EmitBundleAlignMode(4);
- return Streamer;
+ return Streamer;
+ } else {
+ return createMipsELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
+ }
// @LOCALMOD-END
}
diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp
index 58a009ff02..5e0a80f416 100644
--- a/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -13,11 +13,11 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "mips-asm-printer"
-#include "MipsAsmPrinter.h"
#include "InstPrinter/MipsInstPrinter.h"
#include "MCTargetDesc/MipsBaseInfo.h"
#include "MCTargetDesc/MipsELFStreamer.h"
#include "Mips.h"
+#include "MipsAsmPrinter.h"
#include "MipsInstrInfo.h"
#include "MipsMCInstLower.h"
#include "llvm/ADT/SmallString.h"
@@ -67,7 +67,7 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) {
return;
}
- // @LOCALMOD-START
+ // @LOCALMOD-BEGIN:
// Do any auto-generated pseudo lowerings.
if (emitPseudoExpansionLowering(OutStreamer, MI))
return;
@@ -81,15 +81,8 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) {
if (emitPseudoExpansionLowering(OutStreamer, &*I))
continue;
- // The inMips16Mode() test is not permanent.
- // Some instructions are marked as pseudo right now which
- // would make the test fail for the wrong reason but
- // that will be fixed soon. We need this here because we are
- // removing another test for this situation downstream in the
- // callchain.
- //
- if (I->isPseudo() && !Subtarget->inMips16Mode())
- llvm_unreachable("Pseudo opcode found in EmitInstruction()");
+ // @LOCALMOD: the I->isPseudo() assertion here has been removed because
+ // we may have SFI pseudos in I.
MCInst TmpInst0;
MCInstLowering.Lower(I, TmpInst0);
diff --git a/lib/Target/Mips/MipsDelaySlotFiller.cpp b/lib/Target/Mips/MipsDelaySlotFiller.cpp
index af81426bc0..49475d1740 100644
--- a/lib/Target/Mips/MipsDelaySlotFiller.cpp
+++ b/lib/Target/Mips/MipsDelaySlotFiller.cpp
@@ -70,7 +70,6 @@ namespace {
return "Mips Delay Slot Filler";
}
- bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
bool runOnMachineFunction(MachineFunction &F) {
if (SkipDelaySlotFiller)
return false;
@@ -169,7 +168,6 @@ bool RegDefsUses::isRegInSet(const BitVector &RegSet, unsigned Reg) const {
/// We assume there is only one delay slot per delayed instruction.
bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
bool Changed = false;
- LastFiller = MBB.instr_end();
for (Iter I = MBB.begin(); I != MBB.end(); ++I) {
if (!I->hasDelaySlot())
@@ -192,7 +190,6 @@ bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
}
return Changed;
-
}
/// createMipsDelaySlotFillerPass - Returns a pass that fills in delay
@@ -206,11 +203,9 @@ extern bool IsDangerousLoad(const MachineInstr &MI, int *AddrIdx);
extern bool IsDangerousStore(const MachineInstr &MI, int *AddrIdx);
// @LOCALMOD-END
-bool Filler::findDelayInstr(MachineBasicBlock &MBB,
- InstrIter slot,
- InstrIter &Filler) {
- SmallSet<unsigned, 32> RegDefs;
- SmallSet<unsigned, 32> RegUses;
+bool Filler::findDelayInstr(MachineBasicBlock &MBB, Iter Slot,
+ Iter &Filler) const {
+ RegDefsUses RegDU(TM);
RegDU.init(*Slot);
@@ -223,17 +218,22 @@ bool Filler::findDelayInstr(MachineBasicBlock &MBB,
continue;
// @LOCALMOD-START - Don't put in delay slot instructions that could be masked.
- int Dummy;
- if (terminateSearch(*I) || (Triple(TM.getTargetTriple()).isOSNaCl() &&
- (IsDangerousLoad(*FI, &Dummy)
- || IsDangerousStore(*FI, &Dummy)
- || FI->modifiesRegister(Mips::SP, TM.getRegisterInfo()))))
- break;
- // @LOCALMOD-END
//
// Should not allow:
// ERET, DERET or WAIT, PAUSE. Need to add these to instruction
// list. TBD.
+ if (Triple(TM.getTargetTriple()).isOSNaCl()) {
+ int Dummy;
+ Iter FI(llvm::next(I).base());
+ if (terminateSearch(*I) || (IsDangerousLoad(*FI, &Dummy)
+ || IsDangerousStore(*FI, &Dummy)
+ || FI->modifiesRegister(Mips::SP, TM.getRegisterInfo())))
+ break;
+ } else {
+ if (terminateSearch(*I))
+ break;
+ }
+ // @LOCALMOD-END
if (delayHasHazard(*I, SawLoad, SawStore, RegDU))
continue;
diff --git a/lib/Target/Mips/MipsISelDAGToDAG.cpp b/lib/Target/Mips/MipsISelDAGToDAG.cpp
index 7c61318aac..78c74ef879 100644
--- a/lib/Target/Mips/MipsISelDAGToDAG.cpp
+++ b/lib/Target/Mips/MipsISelDAGToDAG.cpp
@@ -392,20 +392,12 @@ bool MipsDAGToDAGISel::selectAddrRegImm(SDValue Addr, SDValue &Base,
}
}
}
+
+ return false;
}
bool MipsDAGToDAGISel::selectAddrDefault(SDValue Addr, SDValue &Base,
SDValue &Offset) const {
- // @LOCALMOD-START
- // If an indexed floating point load/store can be emitted, return false.
- const LSBaseSDNode *LS = dyn_cast<LSBaseSDNode>(Parent);
-
- if (LS &&
- (LS->getMemoryVT() == MVT::f32 || LS->getMemoryVT() == MVT::f64) &&
- Subtarget.hasFPIdx())
- return false;
- // @LOCALMOD-END
-
Base = Addr;
Offset = CurDAG->getTargetConstant(0, Addr.getValueType());
return true;
diff --git a/lib/Target/Mips/MipsInstrFPU.td b/lib/Target/Mips/MipsInstrFPU.td
index 73074f5b58..d22400d211 100644
--- a/lib/Target/Mips/MipsInstrFPU.td
+++ b/lib/Target/Mips/MipsInstrFPU.td
@@ -319,23 +319,23 @@ let Predicates = [NotN64, NotMips64, HasStdEnc] in {
}
// Indexed loads and stores.
-let Predicates = [HasFPIdx, IsNotNaCl/*@LOCALMOD*/] in {
+let Predicates = [HasFPIdx, HasStdEnc, IsNotNaCl/*@LOCALMOD*/] in {
def LWXC1 : LWXC1_FT<"lwxc1", FGR32, CPURegs, IILoad, load>, LWXC1_FM<0>;
def SWXC1 : SWXC1_FT<"swxc1", FGR32, CPURegs, IIStore, store>, SWXC1_FM<8>;
}
-let Predicates = [HasMips32r2, NotMips64, IsNotNaCl/*@LOCALMOD*/] in {
+let Predicates = [HasMips32r2, NotMips64, HasStdEnc, IsNotNaCl/*@LOCALMOD*/] in {
def LDXC1 : LWXC1_FT<"ldxc1", AFGR64, CPURegs, IILoad, load>, LWXC1_FM<1>;
def SDXC1 : SWXC1_FT<"sdxc1", AFGR64, CPURegs, IIStore, store>, SWXC1_FM<9>;
}
-let Predicates = [HasMips64, NotN64, IsNotNaCl/*@LOCALMOD*/], DecoderNamespace="Mips64" in {
+let Predicates = [HasMips64, NotN64, HasStdEnc, IsNotNaCl/*@LOCALMOD*/], DecoderNamespace="Mips64" in {
def LDXC164 : LWXC1_FT<"ldxc1", FGR64, CPURegs, IILoad, load>, LWXC1_FM<1>;
def SDXC164 : SWXC1_FT<"sdxc1", FGR64, CPURegs, IIStore, store>, SWXC1_FM<9>;
}
// n64
-let Predicates = [IsN64, IsNotNaCl/*@LOCALMOD*/], isCodeGenOnly=1 in {
+let Predicates = [IsN64, HasStdEnc, IsNotNaCl/*@LOCALMOD*/], isCodeGenOnly=1 in {
def LWXC1_P8 : LWXC1_FT<"lwxc1", FGR32, CPU64Regs, IILoad, load>, LWXC1_FM<0>;
def LDXC164_P8 : LWXC1_FT<"ldxc1", FGR64, CPU64Regs, IILoad, load>,
LWXC1_FM<1>;
diff --git a/lib/Target/Mips/MipsMCInstLower.cpp b/lib/Target/Mips/MipsMCInstLower.cpp
index e0d884dfda..d836975eb7 100644
--- a/lib/Target/Mips/MipsMCInstLower.cpp
+++ b/lib/Target/Mips/MipsMCInstLower.cpp
@@ -164,4 +164,3 @@ void MipsMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
}
}
-
diff --git a/lib/Target/Mips/MipsNaClRewritePass.cpp b/lib/Target/Mips/MipsNaClRewritePass.cpp
index 5e4e5e3b8f..d4407e835e 100644
--- a/lib/Target/Mips/MipsNaClRewritePass.cpp
+++ b/lib/Target/Mips/MipsNaClRewritePass.cpp
@@ -112,6 +112,7 @@ void MipsNaClRewritePass::SandboxStackChange(MachineBasicBlock &MBB,
// Get to next instr (one + to get the original, and one more + to get past).
MachineBasicBlock::iterator MBBINext = (MBBI++);
+ (void) MBBINext;
MachineBasicBlock::iterator MBBINext2 = (MBBI++);
BuildMI(MBB, MBBINext2, MI.getDebugLoc(),
diff --git a/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp b/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
index 370eebe1f3..2039b7d210 100644
--- a/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
+++ b/<