[llvm] r269544 - ThinLTOCodeGenerator: handle cases where temporary files can't be renamed

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri May 13 22:16:35 PDT 2016


Author: mehdi_amini
Date: Sat May 14 00:16:35 2016
New Revision: 269544

URL: http://llvm.org/viewvc/llvm-project?rev=269544&view=rev
Log:
ThinLTOCodeGenerator: handle cases where temporary files can't be renamed

For instance when they're on different filesystem.

From: Mehdi Amini <mehdi.amini at apple.com>

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

Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=269544&r1=269543&r2=269544&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Sat May 14 00:16:35 2016
@@ -504,8 +504,12 @@ public:
     // Rename to final destination (hopefully race condition won't matter here)
     EC = sys::fs::rename(TempFilename, EntryPath);
     if (EC) {
-      errs() << "Error: " << EC.message() << "\n";
-      report_fatal_error("ThinLTO: Can't rename temporary file " + TempFilename + " to " + EntryPath);
+      sys::fs::remove(TempFilename);
+      raw_fd_ostream OS(EntryPath, EC, sys::fs::F_None);
+      if (EC)
+        report_fatal_error(Twine("Failed to open ") + EntryPath +
+                           " to save cached entry\n");
+      OS << OutputBuffer.getBuffer();
     }
   }
 };




More information about the llvm-commits mailing list