[PATCH] D51095: [LLD] [RFC] Don't close the memory mapping when exiting

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 11:37:24 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL340634: [Support] Allow discarding a FileOutputBuffer without removing the memory… (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51095?vs=161916&id=162434#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51095

Files:
  llvm/trunk/include/llvm/Support/FileOutputBuffer.h
  llvm/trunk/lib/Support/FileOutputBuffer.cpp


Index: llvm/trunk/lib/Support/FileOutputBuffer.cpp
===================================================================
--- llvm/trunk/lib/Support/FileOutputBuffer.cpp
+++ llvm/trunk/lib/Support/FileOutputBuffer.cpp
@@ -61,6 +61,12 @@
     consumeError(Temp.discard());
   }
 
+  void discard() override {
+    // Delete the temp file if it still was open, but keeping the mapping
+    // active.
+    consumeError(Temp.discard());
+  }
+
 private:
   std::unique_ptr<fs::mapped_file_region> Buffer;
   fs::TempFile Temp;
Index: llvm/trunk/include/llvm/Support/FileOutputBuffer.h
===================================================================
--- llvm/trunk/include/llvm/Support/FileOutputBuffer.h
+++ llvm/trunk/include/llvm/Support/FileOutputBuffer.h
@@ -76,6 +76,10 @@
   /// deallocates the buffer and the target file is never written.
   virtual ~FileOutputBuffer() {}
 
+  /// This removes the temporary file (unless it already was committed)
+  /// but keeps the memory mapping alive.
+  virtual void discard() {}
+
 protected:
   FileOutputBuffer(StringRef Path) : FinalPath(Path) {}
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51095.162434.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180824/6d2bbaf8/attachment.bin>


More information about the llvm-commits mailing list