From 289792dbcaee2a2ff7345e3291971e9d3aa27b28 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 26 Jan 2017 02:07:05 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293132 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/tools/gold/X86/parallel.ll | 4 ++-- tools/gold/gold-plugin.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/tools/gold/X86/parallel.ll b/test/tools/gold/X86/parallel.ll index 52232918c80..4de694c94c8 100644 --- a/test/tools/gold/X86/parallel.ll +++ b/test/tools/gold/X86/parallel.ll @@ -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" diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 1ac542b2876..f8e70807613 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -106,7 +106,6 @@ static DenseMap FDToLeaderHandle; static StringMap ResInfo; static std::vector Cleanup; static llvm::TargetOptions TargetOpts; -static size_t MaxTasks; namespace options { enum OutputType { @@ -637,7 +636,7 @@ static void recordFile(std::string Filename, bool TempOutFile) { /// 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(SmallString<128> InFilename, bool TempOutFile, EC.message().c_str()); } else { NewFilename = InFilename; - if (TaskID >= 0) + if (TaskID > 0) NewFilename += utostr(TaskID); } } @@ -813,7 +812,7 @@ static ld_plugin_status allSymbolsReadHook() { Filename = output_name + ".o"; bool SaveTemps = !Filename.empty(); - MaxTasks = Lto->getMaxTasks(); + size_t MaxTasks = Lto->getMaxTasks(); std::vector IsTemporary(MaxTasks); std::vector> Filenames(MaxTasks); @@ -821,7 +820,7 @@ static ld_plugin_status allSymbolsReadHook() { [&](size_t Task) -> std::unique_ptr { 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); -- 2.40.0