Revert the last couple of patches here and go back to something
[oota-llvm.git] / lib / LTO / LTOCodeGenerator.cpp
index 777db9c9128db2057a6443febe4856266bb3c854..51d089988178fb40d39966b25c9b820a2fba8fa7 100644 (file)
@@ -29,7 +29,7 @@
 #include "llvm/IR/Verifier.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/LTO/LTOModule.h"
-#include "llvm/Linker.h"
+#include "llvm/Linker/Linker.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
 #include "llvm/Target/TargetLibraryInfo.h"
 #include "llvm/Target/TargetLowering.h"
@@ -65,8 +65,7 @@ const char* LTOCodeGenerator::getVersionString() {
 LTOCodeGenerator::LTOCodeGenerator()
     : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
       TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
-      CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
-      InternalizeStrategy(LTO_INTERNALIZE_FULL), NativeObjectFile(NULL),
+      CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL),
       DiagHandler(NULL), DiagContext(NULL) {
   initializeLTOPasses();
 }
@@ -169,18 +168,6 @@ void LTOCodeGenerator::setCodePICModel(lto_codegen_model model) {
   llvm_unreachable("Unknown PIC model!");
 }
 
-void
-LTOCodeGenerator::setInternalizeStrategy(lto_internalize_strategy Strategy) {
-  switch (Strategy) {
-  case LTO_INTERNALIZE_FULL:
-  case LTO_INTERNALIZE_NONE:
-  case LTO_INTERNALIZE_HIDDEN:
-    InternalizeStrategy = Strategy;
-    return;
-  }
-  llvm_unreachable("Unknown internalize strategy!");
-}
-
 bool LTOCodeGenerator::writeMergedModules(const char *path,
                                           std::string &errMsg) {
   if (!determineTarget(errMsg))
@@ -264,13 +251,13 @@ const void* LTOCodeGenerator::compile(size_t* length,
   delete NativeObjectFile;
 
   // read .o file into memory buffer
-  OwningPtr<MemoryBuffer> BuffPtr;
+  std::unique_ptr<MemoryBuffer> BuffPtr;
   if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
     errMsg = ec.message();
     sys::fs::remove(NativeObjectPath);
     return NULL;
   }
-  NativeObjectFile = BuffPtr.take();
+  NativeObjectFile = BuffPtr.release();
 
   // remove temp files
   sys::fs::remove(NativeObjectPath);
@@ -321,6 +308,8 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
       MCpu = "core2";
     else if (Triple.getArch() == llvm::Triple::x86)
       MCpu = "yonah";
+    else if (Triple.getArch() == llvm::Triple::arm64)
+      MCpu = "cyclone";
   }
 
   TargetMach = march->createTargetMachine(TripleStr, MCpu, FeatureStr, Options,
@@ -400,7 +389,7 @@ static void accumulateAndSortLibcalls(std::vector<StringRef> &Libcalls,
 }
 
 void LTOCodeGenerator::applyScopeRestrictions() {
-  if (ScopeRestrictionsDone || !shouldInternalize())
+  if (ScopeRestrictionsDone)
     return;
   Module *mergedModule = Linker.getModule();
 
@@ -452,8 +441,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
     LLVMCompilerUsed->setSection("llvm.metadata");
   }
 
-  passes.add(
-      createInternalizePass(MustPreserveList, shouldOnlyInternalizeHidden()));
+  passes.add(createInternalizePass(MustPreserveList));
 
   // apply scope restrictions
   passes.run(*mergedModule);