[PATCH] D43396: [ThinLTO/gold] Avoid race with cache pruner by copying to temp files
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 10:36:38 PST 2018
tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added a subscriber: inglorion.
This will avoid the race condition described in the review for https://reviews.llvm.org/D37993.
I believe that the Path parameter to AddBufferFn is no longer utilized.
I would prefer to remove that as a follow up clean up patch to reduce
the diffs in this patch.
Repository:
rL LLVM
https://reviews.llvm.org/D43396
Files:
test/tools/gold/X86/cache.ll
tools/gold/gold-plugin.cpp
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -903,9 +903,7 @@
auto AddBuffer = [&](size_t Task, std::unique_ptr<MemoryBuffer> MB,
StringRef Path) {
- // Note that this requires that the memory buffers provided to AddBuffer are
- // backed by a file.
- Filenames[Task] = Path;
+ *AddStream(Task)->OS << MB->getBuffer();
};
NativeObjectCache Cache;
Index: test/tools/gold/X86/cache.ll
===================================================================
--- test/tools/gold/X86/cache.ll
+++ test/tools/gold/X86/cache.ll
@@ -56,10 +56,16 @@
; This should remove it.
; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
; RUN: --plugin-opt=thinlto \
+; RUN: --plugin-opt=save-temps \
; RUN: --plugin-opt=cache-dir=%t.cache \
; RUN: --plugin-opt=cache-policy=cache_size_bytes=32k:prune_interval=0s \
-; RUN: -o %t3.o %t2.o %t.o
+; RUN: -o %t4.o %t2.o %t.o
; RUN: ls %t.cache | count 4
+; With save-temps we can confirm that the cached files were copied into temp
+; files to avoid a race condition with the cached files being pruned, since the
+; gold plugin-api only accepts native objects passed back as files.
+; RUN: ls %t4.o.o1
+; RUN: ls %t4.o.o2
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43396.134652.patch
Type: text/x-patch
Size: 1429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180216/f8feefd8/attachment.bin>
More information about the llvm-commits
mailing list