From 0b1914e83a03be926569892c17ca743c5ea46d1f Mon Sep 17 00:00:00 2001 From: Hongtao Yu Date: Fri, 5 Feb 2021 13:17:51 -0800 Subject: [ThinLTO][gold] Fix filenaming scheme for tasks. The gold LTO plugin uses a set of hooks to implements emit-llvm and capture intermediate file generated during LTO. The hooks are called by each lto backend thread with a taskID as argument to differentiate between threads and tasks. Currently, all threads are overwriting the same file which results into only the intermediate output of the last backend thread to be preserved. This diff encodes the taskID into the filename. Reviewed By: tejohnson, wenlei Differential Revision: https://reviews.llvm.org/D96173 --- llvm/tools/gold/gold-plugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/tools/gold') diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index c0e0d5b..38f9596 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -915,7 +915,10 @@ static std::unique_ptr createLTO(IndexWriteCallback OnIndexWrite, case options::OT_BC_ONLY: Conf.PostInternalizeModuleHook = [](size_t Task, const Module &M) { std::error_code EC; - raw_fd_ostream OS(output_name, EC, sys::fs::OpenFlags::OF_None); + SmallString<128> TaskFilename; + getOutputFileName(output_name, /* TempOutFile */ false, TaskFilename, + Task); + raw_fd_ostream OS(TaskFilename, EC, sys::fs::OpenFlags::OF_None); if (EC) message(LDPL_FATAL, "Failed to write the output file."); WriteBitcodeToFile(M, OS, /* ShouldPreserveUseListOrder */ false); -- cgit v1.1