aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-12-11 00:27:20 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-12-11 00:27:20 +0000
commit475ddb4547ce35706ce1ff54b14bdcfdc51954c2 (patch)
treedff9a7b6e255e35fe74f0f1e02c6570c5082a1f9
parent737061fc2948776f941e1854a9bc6ebd070d9151 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91082 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Basic/FileManager.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 9c5f1d59c1..434ff39e77 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -378,17 +378,16 @@ void FileManager::PrintStats() const {
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;
}