[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
Tue Feb 20 11:55:20 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL325618: [ThinLTO/gold] Avoid race with cache pruner by copying to temp files (authored by tejohnson, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D43396

Files:
  llvm/trunk/test/tools/gold/X86/cache.ll
  llvm/trunk/tools/gold/gold-plugin.cpp


Index: llvm/trunk/tools/gold/gold-plugin.cpp
===================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp
+++ llvm/trunk/tools/gold/gold-plugin.cpp
@@ -919,9 +919,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: llvm/trunk/test/tools/gold/X86/cache.ll
===================================================================
--- llvm/trunk/test/tools/gold/X86/cache.ll
+++ llvm/trunk/test/tools/gold/X86/cache.ll
@@ -54,10 +54,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.135118.patch
Type: text/x-patch
Size: 1495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180220/ee8fc211/attachment.bin>


More information about the llvm-commits mailing list