summaryrefslogtreecommitdiffstats
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
commit2f1a6c110428d5cdef9fb9e414e083220fd3e47a (patch)
tree01bba3bbc5e0f6eef8bb4f36effc182a8aaf57cb
parent73fab4f3f49b7897284d7f5062f6efcc067eb550 (diff)
downloadbcm5719-llvm-2f1a6c110428d5cdef9fb9e414e083220fd3e47a.tar.gz
bcm5719-llvm-2f1a6c110428d5cdef9fb9e414e083220fd3e47a.zip
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. llvm-svn: 91082
-rw-r--r--clang/lib/Basic/FileManager.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 9c5f1d59c19..434ff39e77e 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud