[llvm-branch-commits] [llvm-branch] r292731 - LLVM 4.0: cherry-pick r292667 [ThinLTO] The "codegen only" path didn't honor the recently added file-based API

Mehdi Amini via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Jan 21 14:08:38 PST 2017


Author: mehdi_amini
Date: Sat Jan 21 16:08:38 2017
New Revision: 292731

URL: http://llvm.org/viewvc/llvm-project?rev=292731&view=rev
Log:
LLVM 4.0: cherry-pick r292667 [ThinLTO] The "codegen only" path didn't honor the recently added file-based API


Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 21 16:08:38 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280
+/llvm/trunk:155241,291863,291875,291966,291968,291979,292133,292242,292254-292255,292280,292667

Modified: llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp?rev=292731&r1=292730&r2=292731&view=diff
==============================================================================
--- llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp (original)
+++ llvm/branches/release_40/lib/LTO/ThinLTOCodeGenerator.cpp Sat Jan 21 16:08:38 2017
@@ -829,11 +829,22 @@ static std::string writeGeneratedObject(
 
 // Main entry point for the ThinLTO processing
 void ThinLTOCodeGenerator::run() {
+  // Prepare the resulting object vector
+  assert(ProducedBinaries.empty() && "The generator should not be reused");
+  if (SavedObjectsDirectoryPath.empty())
+    ProducedBinaries.resize(Modules.size());
+  else {
+    sys::fs::create_directories(SavedObjectsDirectoryPath);
+    bool IsDir;
+    sys::fs::is_directory(SavedObjectsDirectoryPath, IsDir);
+    if (!IsDir)
+      report_fatal_error("Unexistent dir: '" + SavedObjectsDirectoryPath + "'");
+    ProducedBinaryFiles.resize(Modules.size());
+  }
+
   if (CodeGenOnly) {
     // Perform only parallel codegen and return.
     ThreadPool Pool;
-    assert(ProducedBinaries.empty() && "The generator should not be reused");
-    ProducedBinaries.resize(Modules.size());
     int count = 0;
     for (auto &ModuleBuffer : Modules) {
       Pool.async([&](int count) {
@@ -845,7 +856,12 @@ void ThinLTOCodeGenerator::run() {
                                               /*IsImporting*/ false);
 
         // CodeGen
-        ProducedBinaries[count] = codegen(*TheModule);
+        auto OutputBuffer = codegen(*TheModule);
+        if (SavedObjectsDirectoryPath.empty())
+          ProducedBinaries[count] = std::move(OutputBuffer);
+        else
+          ProducedBinaryFiles[count] = writeGeneratedObject(
+              count, "", SavedObjectsDirectoryPath, *OutputBuffer);
       }, count++);
     }
 
@@ -866,18 +882,6 @@ void ThinLTOCodeGenerator::run() {
     WriteIndexToFile(*Index, OS);
   }
 
-  // Prepare the resulting object vector
-  assert(ProducedBinaries.empty() && "The generator should not be reused");
-  if (SavedObjectsDirectoryPath.empty())
-    ProducedBinaries.resize(Modules.size());
-  else {
-    sys::fs::create_directories(SavedObjectsDirectoryPath);
-    bool IsDir;
-    sys::fs::is_directory(SavedObjectsDirectoryPath, IsDir);
-    if (!IsDir)
-      report_fatal_error("Unexistent dir: '" + SavedObjectsDirectoryPath + "'");
-    ProducedBinaryFiles.resize(Modules.size());
-  }
 
   // Prepare the module map.
   auto ModuleMap = generateModuleMap(Modules);




More information about the llvm-branch-commits mailing list