[cfe-commits] r91082 - /cfe/trunk/lib/Basic/FileManager.cpp

Daniel Dunbar daniel at zuster.org
Thu Dec 10 16:27:20 PST 2009


Author: ddunbar
Date: Thu Dec 10 18:27:20 2009
New Revision: 91082

URL: http://llvm.org/viewvc/llvm-project?rev=91082&view=rev
Log:
FileManager: Do not cache failed stats, it is easy to construct common
inconsistent situations if we do, and they are not important for PCH performance
(which currently only needs the stats to construct the initial FileManager
entries).
 - No test case, sorry, the machinations are too involved.

This occurs when, for example, the build makes a PCH file and has a header map
or a -I for a directory that does not yet exist. It is possible we will cache
the negative stat on that directory, and then in the build we will never find
header files inside that dir.

For PCH we don't need these stats anyway for performance, so this also makes PCH
files smaller w/ no loss. I hope to eventually eliminate the stat cache
entirely.

Modified:
    cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=91082&r1=91081&r2=91082&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Thu Dec 10 18:27:20 2009
@@ -378,17 +378,16 @@
 int MemorizeStatCalls::stat(const char *path, struct stat *buf) {
   int result = StatSysCallCache::stat(path, buf);
   
-  if (result != 0) {
-    // Cache failed 'stat' results.
-    struct stat empty;
-    memset(&empty, 0, sizeof(empty));
-    StatCalls[path] = StatResult(result, empty);
-  }
-  else if (!S_ISDIR(buf->st_mode) || llvm::sys::Path(path).isAbsolute()) {
-    // Cache file 'stat' results and directories with absolutely
-    // paths.
+  // Do not cache failed stats, it is easy to construct common inconsistent
+  // situations if we do, and they are not important for PCH performance (which
+  // currently only needs the stats to construct the initial FileManager
+  // entries).
+  if (result != 0)
+    return result;
+
+  // Cache file 'stat' results and directories with absolutely paths.
+  if (!S_ISDIR(buf->st_mode) || llvm::sys::Path(path).isAbsolute())
     StatCalls[path] = StatResult(result, *buf);
-  }
 
   return result;
 }





More information about the cfe-commits mailing list