@@ -777,11 +777,13 @@ void ThinLTOCodeGenerator::optimize(Module &TheModule) {
777777// / Write out the generated object file, either from CacheEntryPath or from
778778// / OutputBuffer, preferring hard-link when possible.
779779// / Returns the path to the generated file in SavedObjectsDirectoryPath.
780- static std::string writeGeneratedObject (int count, StringRef CacheEntryPath,
781- StringRef SavedObjectsDirectoryPath,
782- const MemoryBuffer &OutputBuffer) {
780+ std::string
781+ ThinLTOCodeGenerator::writeGeneratedObject (int count, StringRef CacheEntryPath,
782+ const MemoryBuffer &OutputBuffer) {
783+ auto ArchName = TMBuilder.TheTriple .getArchName ();
783784 SmallString<128 > OutputPath (SavedObjectsDirectoryPath);
784- llvm::sys::path::append (OutputPath, Twine (count) + " .thinlto.o" );
785+ llvm::sys::path::append (OutputPath,
786+ Twine (count) + " ." + ArchName + " .thinlto.o" );
785787 OutputPath.c_str (); // Ensure the string is null terminated.
786788 if (sys::fs::exists (OutputPath))
787789 sys::fs::remove (OutputPath);
@@ -845,8 +847,8 @@ void ThinLTOCodeGenerator::run() {
845847 if (SavedObjectsDirectoryPath.empty ())
846848 ProducedBinaries[count] = std::move (OutputBuffer);
847849 else
848- ProducedBinaryFiles[count] = writeGeneratedObject (
849- count, " " , SavedObjectsDirectoryPath , *OutputBuffer);
850+ ProducedBinaryFiles[count] =
851+ writeGeneratedObject ( count, " " , *OutputBuffer);
850852 }, count++);
851853 }
852854
@@ -963,8 +965,7 @@ void ThinLTOCodeGenerator::run() {
963965 ProducedBinaries[count] = std::move (ErrOrBuffer.get ());
964966 else
965967 ProducedBinaryFiles[count] = writeGeneratedObject (
966- count, CacheEntryPath, SavedObjectsDirectoryPath,
967- *ErrOrBuffer.get ());
968+ count, CacheEntryPath, *ErrOrBuffer.get ());
968969 return ;
969970 }
970971 }
@@ -1021,7 +1022,7 @@ void ThinLTOCodeGenerator::run() {
10211022 return ;
10221023 }
10231024 ProducedBinaryFiles[count] = writeGeneratedObject (
1024- count, CacheEntryPath, SavedObjectsDirectoryPath, *OutputBuffer);
1025+ count, CacheEntryPath, *OutputBuffer);
10251026 }, IndexCount);
10261027 }
10271028 }
0 commit comments