[PATCH] D112124: [ThinLTO] Append original object file name to ThinLTO generated object file's name, so that it can be recorded in link map file.
Xu ShuangQing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 21 19:49:25 PDT 2021
xushuangqing updated this revision to Diff 381460.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112124/new/
https://reviews.llvm.org/D112124
Files:
llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/test/ThinLTO/X86/save_objects.ll
Index: llvm/test/ThinLTO/X86/save_objects.ll
===================================================================
--- llvm/test/ThinLTO/X86/save_objects.ll
+++ llvm/test/ThinLTO/X86/save_objects.ll
@@ -21,7 +21,7 @@
; RUN: ls %t.cache | count 3
; Check the name of object in directory has arch name included.
-; RUN: ls %t.thin.out | grep x86_64.thinlto.o | count 2
+; RUN: ls %t.thin.out | grep "x86_64\..*thinlto\.o" | count 2
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -964,11 +964,16 @@
/// Returns the path to the generated file in SavedObjectsDirectoryPath.
std::string
ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
- const MemoryBuffer &OutputBuffer) {
+ const MemoryBuffer &OutputBuffer,
+ StringRef objectFileName) {
auto ArchName = TMBuilder.TheTriple.getArchName();
SmallString<128> OutputPath(SavedObjectsDirectoryPath);
- llvm::sys::path::append(OutputPath,
- Twine(count) + "." + ArchName + ".thinlto.o");
+ if (objectFileName.empty())
+ llvm::sys::path::append(OutputPath,
+ Twine(count) + "." + ArchName + ".thinlto.o");
+ else
+ llvm::sys::path::append(OutputPath, Twine(count) + "." + ArchName + "." +
+ objectFileName + ".thinlto.o");
OutputPath.c_str(); // Ensure the string is null terminated.
if (sys::fs::exists(OutputPath))
sys::fs::remove(OutputPath);
@@ -1164,6 +1169,10 @@
auto &Mod = Modules[IndexCount];
Pool.async([&](int count) {
auto ModuleIdentifier = Mod->getName();
+
+ StringRef moduleIdentifierFileName =
+ llvm::sys::path::filename(ModuleIdentifier);
+
auto &ExportList = ExportLists[ModuleIdentifier];
auto &DefinedGVSummaries = ModuleToDefinedGVSummaries[ModuleIdentifier];
@@ -1188,7 +1197,8 @@
ProducedBinaries[count] = std::move(ErrOrBuffer.get());
else
ProducedBinaryFiles[count] = writeGeneratedObject(
- count, CacheEntryPath, *ErrOrBuffer.get());
+ count, CacheEntryPath, *ErrOrBuffer.get(),
+ moduleIdentifierFileName);
return;
}
}
@@ -1246,7 +1256,7 @@
return;
}
ProducedBinaryFiles[count] = writeGeneratedObject(
- count, CacheEntryPath, *OutputBuffer);
+ count, CacheEntryPath, *OutputBuffer, moduleIdentifierFileName);
}, IndexCount);
}
}
Index: llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
===================================================================
--- llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
+++ llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
@@ -299,7 +299,8 @@
* SavedObjectsDirectoryPath.
*/
std::string writeGeneratedObject(int count, StringRef CacheEntryPath,
- const MemoryBuffer &OutputBuffer);
+ const MemoryBuffer &OutputBuffer,
+ StringRef objectFileName = "");
/**@}*/
private:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112124.381460.patch
Type: text/x-patch
Size: 3491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211022/ef14cb7e/attachment.bin>
More information about the llvm-commits
mailing list