[lld] 6bda276 - [LLD][ELF][Windows] small improvement to D82567

Ben Dunbobbin via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 04:02:30 PDT 2020


Author: Ben Dunbobbin
Date: 2020-07-13T12:02:20+01:00
New Revision: 6bda276f93023ae91937cb8a1f45bf27e5a3ced7

URL: https://github.com/llvm/llvm-project/commit/6bda276f93023ae91937cb8a1f45bf27e5a3ced7
DIFF: https://github.com/llvm/llvm-project/commit/6bda276f93023ae91937cb8a1f45bf27e5a3ced7.diff

LOG: [LLD][ELF][Windows] small improvement to D82567

Bail early if there is no existing output file to be overwritten.

Differential Revision: https://reviews.llvm.org/D83272

Added: 
    

Modified: 
    lld/Common/Filesystem.cpp

Removed: 
    


################################################################################
diff  --git a/lld/Common/Filesystem.cpp b/lld/Common/Filesystem.cpp
index 206b892f0a69..671b352a3f6b 100644
--- a/lld/Common/Filesystem.cpp
+++ b/lld/Common/Filesystem.cpp
@@ -40,6 +40,9 @@ using namespace lld;
 // This function spawns a background thread to remove the file.
 // The calling thread returns almost immediately.
 void lld::unlinkAsync(StringRef path) {
+  if (!sys::fs::exists(path) || !sys::fs::is_regular_file(path))
+    return;
+
 // Removing a file is async on windows.
 #if defined(_WIN32)
   // On Windows co-operative programs can be expected to open LLD's
@@ -71,8 +74,7 @@ void lld::unlinkAsync(StringRef path) {
   }
   sys::fs::remove(path);
 #else
-  if (parallel::strategy.ThreadsRequested == 1 || !sys::fs::exists(path) ||
-      !sys::fs::is_regular_file(path))
+  if (parallel::strategy.ThreadsRequested == 1)
     return;
 
   // We cannot just remove path from a 
diff erent thread because we are now going


        


More information about the llvm-commits mailing list