[llvm] r293132 - gold-plugin: Simplify naming of object files created with save-temps or obj-path.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 18:07:06 PST 2017


Author: pcc
Date: Wed Jan 25 20:07:05 2017
New Revision: 293132

URL: http://llvm.org/viewvc/llvm-project?rev=293132&view=rev
Log:
gold-plugin: Simplify naming of object files created with save-temps or obj-path.

Now we never append a number to the file name for task ID 0.

Differential Revision: https://reviews.llvm.org/D29160

Modified:
    llvm/trunk/test/tools/gold/X86/parallel.ll
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/test/tools/gold/X86/parallel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/X86/parallel.ll?rev=293132&r1=293131&r2=293132&view=diff
==============================================================================
--- llvm/trunk/test/tools/gold/X86/parallel.ll (original)
+++ llvm/trunk/test/tools/gold/X86/parallel.ll Wed Jan 25 20:07:05 2017
@@ -1,9 +1,9 @@
 ; RUN: llvm-as -o %t.bc %s
-; RUN: rm -f %t.opt.bc0 %t.opt.bc1 %t.o0 %t.o1
+; RUN: rm -f %t.0.5.precodegen.bc %t.1.5.precodegen.bc %t.o %t.o1
 ; RUN: env LD_PRELOAD=%llvmshlibdir/LLVMgold.so %gold -plugin %llvmshlibdir/LLVMgold.so -u foo -u bar -plugin-opt lto-partitions=2 -plugin-opt save-temps -m elf_x86_64 -o %t %t.bc
 ; RUN: llvm-dis %t.0.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC0 %s
 ; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC1 %s
-; RUN: llvm-nm %t.o0 | FileCheck --check-prefix=CHECK0 %s
+; RUN: llvm-nm %t.o | FileCheck --check-prefix=CHECK0 %s
 ; RUN: llvm-nm %t.o1 | FileCheck --check-prefix=CHECK1 %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=293132&r1=293131&r2=293132&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Wed Jan 25 20:07:05 2017
@@ -106,7 +106,6 @@ static DenseMap<int, void *> FDToLeaderH
 static StringMap<ResolutionInfo> ResInfo;
 static std::vector<std::string> Cleanup;
 static llvm::TargetOptions TargetOpts;
-static size_t MaxTasks;
 
 namespace options {
   enum OutputType {
@@ -637,7 +636,7 @@ static void recordFile(std::string Filen
 /// indicating whether a temp file should be generated, and an optional task id.
 /// The new filename generated is returned in \p NewFilename.
 static void getOutputFileName(SmallString<128> InFilename, bool TempOutFile,
-                              SmallString<128> &NewFilename, int TaskID = -1) {
+                              SmallString<128> &NewFilename, int TaskID) {
   if (TempOutFile) {
     std::error_code EC =
         sys::fs::createTemporaryFile("lto-llvm", "o", NewFilename);
@@ -646,7 +645,7 @@ static void getOutputFileName(SmallStrin
               EC.message().c_str());
   } else {
     NewFilename = InFilename;
-    if (TaskID >= 0)
+    if (TaskID > 0)
       NewFilename += utostr(TaskID);
   }
 }
@@ -813,7 +812,7 @@ static ld_plugin_status allSymbolsReadHo
     Filename = output_name + ".o";
   bool SaveTemps = !Filename.empty();
 
-  MaxTasks = Lto->getMaxTasks();
+  size_t MaxTasks = Lto->getMaxTasks();
   std::vector<uintptr_t> IsTemporary(MaxTasks);
   std::vector<SmallString<128>> Filenames(MaxTasks);
 
@@ -821,7 +820,7 @@ static ld_plugin_status allSymbolsReadHo
       [&](size_t Task) -> std::unique_ptr<lto::NativeObjectStream> {
     IsTemporary[Task] = !SaveTemps;
     getOutputFileName(Filename, /*TempOutFile=*/!SaveTemps, Filenames[Task],
-                      MaxTasks > 1 ? Task : -1);
+                      Task);
     int FD;
     std::error_code EC =
         sys::fs::openFileForWrite(Filenames[Task], FD, sys::fs::F_None);




More information about the llvm-commits mailing list