[llvm] r312683 - LTO: Remove unnecessary Windows support code.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 17:55:00 PDT 2017


Author: pcc
Date: Wed Sep  6 17:55:00 2017
New Revision: 312683

URL: http://llvm.org/viewvc/llvm-project?rev=312683&view=rev
Log:
LTO: Remove unnecessary Windows support code.

I empirically verified that open files can in fact be renamed on
Windows with sys::fs::rename, so remove the incorrect code and comment.

Modified:
    llvm/trunk/lib/LTO/Caching.cpp

Modified: llvm/trunk/lib/LTO/Caching.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/Caching.cpp?rev=312683&r1=312682&r2=312683&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/Caching.cpp (original)
+++ llvm/trunk/lib/LTO/Caching.cpp Wed Sep  6 17:55:00 2017
@@ -63,20 +63,6 @@ Expected<NativeObjectCache> lto::localCa
         // Make sure the file is closed before committing it.
         OS.reset();
 
-#ifdef _WIN32
-        // Rename the file first on Windows because we cannot rename an open
-        // file on that platform using the sys::fs::rename function.
-        // FIXME: This code could race with the cache pruner, but it is unlikely
-        // that the cache pruner will choose to remove a newly created file.
-        // We should look at using the SetFileInformationByHandle function to
-        // rename the file while it is open.
-        if (auto EC = sys::fs::rename(TempFilename, EntryPath))
-          report_fatal_error(Twine("Failed to rename temporary file ") +
-                             TempFilename + ": " + EC.message() + "\n");
-
-        ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
-            MemoryBuffer::getFile(EntryPath);
-#else
         // Open the file first to avoid racing with a cache pruner.
         ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
             MemoryBuffer::getFile(TempFilename);
@@ -85,7 +71,6 @@ Expected<NativeObjectCache> lto::localCa
         if (auto EC = sys::fs::rename(TempFilename, EntryPath))
           report_fatal_error(Twine("Failed to rename temporary file ") +
                              TempFilename + ": " + EC.message() + "\n");
-#endif
 
         if (!MBOrErr)
           report_fatal_error(Twine("Failed to open cache file ") + EntryPath +




More information about the llvm-commits mailing list