llvm.org GIT mirror llvm / 289792d
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 Peter Collingbourne 3 years ago
2 changed file(s) with 6 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as -o %t.bc %s
1 ; RUN: rm -f %t.opt.bc0 %t.opt.bc1 %t.o0 %t.o1
1 ; RUN: rm -f %t.0.5.precodegen.bc %t.1.5.precodegen.bc %t.o %t.o1
22 ; 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
33 ; RUN: llvm-dis %t.0.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC0 %s
44 ; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck --check-prefix=CHECK-BC1 %s
5 ; RUN: llvm-nm %t.o0 | FileCheck --check-prefix=CHECK0 %s
5 ; RUN: llvm-nm %t.o | FileCheck --check-prefix=CHECK0 %s
66 ; RUN: llvm-nm %t.o1 | FileCheck --check-prefix=CHECK1 %s
77
88 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
105105 static StringMap ResInfo;
106106 static std::vector Cleanup;
107107 static llvm::TargetOptions TargetOpts;
108 static size_t MaxTasks;
109108
110109 namespace options {
111110 enum OutputType {
636635 /// indicating whether a temp file should be generated, and an optional task id.
637636 /// The new filename generated is returned in \p NewFilename.
638637 static void getOutputFileName(SmallString<128> InFilename, bool TempOutFile,
639 SmallString<128> &NewFilename, int TaskID = -1) {
638 SmallString<128> &NewFilename, int TaskID) {
640639 if (TempOutFile) {
641640 std::error_code EC =
642641 sys::fs::createTemporaryFile("lto-llvm", "o", NewFilename);
645644 EC.message().c_str());
646645 } else {
647646 NewFilename = InFilename;
648 if (TaskID >= 0)
647 if (TaskID > 0)
649648 NewFilename += utostr(TaskID);
650649 }
651650 }
812811 Filename = output_name + ".o";
813812 bool SaveTemps = !Filename.empty();
814813
815 MaxTasks = Lto->getMaxTasks();
814 size_t MaxTasks = Lto->getMaxTasks();
816815 std::vector IsTemporary(MaxTasks);
817816 std::vector> Filenames(MaxTasks);
818817
820819 [&](size_t Task) -> std::unique_ptr {
821820 IsTemporary[Task] = !SaveTemps;
822821 getOutputFileName(Filename, /*TempOutFile=*/!SaveTemps, Filenames[Task],
823 MaxTasks > 1 ? Task : -1);
822 Task);
824823 int FD;
825824 std::error_code EC =
826825 sys::fs::openFileForWrite(Filenames[Task], FD, sys::fs::F_None);