Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit 082dec2

Browse files
committed
Merge remote-tracking branch 'origin/swift-5.1-branch' into stable
2 parents 77814f8 + 59470d4 commit 082dec2

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

include/llvm/LTO/legacy/ThinLTOCodeGenerator.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,13 @@ class ThinLTOCodeGenerator {
299299
*/
300300
void optimize(Module &Module);
301301

302+
/**
303+
* Write temporary object file to SavedObjectDirectoryPath, write symlink
304+
* to Cache directory if needed. Returns the path to the generated file in
305+
* SavedObjectsDirectoryPath.
306+
*/
307+
std::string writeGeneratedObject(int count, StringRef CacheEntryPath,
308+
const MemoryBuffer &OutputBuffer);
302309
/**@}*/
303310

304311
private:

lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

test/ThinLTO/X86/save_objects.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
; RUN: ls %t.thin.out | count 2
2121
; RUN: ls %t.cache | count 3
2222

23+
; Check the name of object in directory has arch name included.
24+
; RUN: ls %t.thin.out | grep x86_64.thinlto.o | count 2
25+
2326

2427
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2528
target triple = "x86_64-apple-macosx10.11.0"

0 commit comments

Comments
 (0)