[cfe-commits] r120031 - in /cfe/trunk: include/clang/Basic/FileSystemStatCache.h lib/Basic/FileSystemStatCache.cpp lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp

Chris Lattner sabre at nondot.org
Tue Nov 23 11:28:12 PST 2010


Author: lattner
Date: Tue Nov 23 13:28:12 2010
New Revision: 120031

URL: http://llvm.org/viewvc/llvm-project?rev=120031&view=rev
Log:
PCH files only cache successful stats.  Remove the code that reads/writes 
the result code of the stat to/from the PCH file since it is always 0.

Modified:
    cfe/trunk/include/clang/Basic/FileSystemStatCache.h
    cfe/trunk/lib/Basic/FileSystemStatCache.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/FileSystemStatCache.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileSystemStatCache.h?rev=120031&r1=120030&r2=120031&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileSystemStatCache.h (original)
+++ cfe/trunk/include/clang/Basic/FileSystemStatCache.h Tue Nov 23 13:28:12 2010
@@ -67,17 +67,10 @@
 /// execution of the front end.
 class MemorizeStatCalls : public FileSystemStatCache {
 public:
-  /// \brief The result of a stat() call.
-  ///
-  /// The first member is the result of calling stat(). If stat()
-  /// found something, the second member is a copy of the stat
-  /// structure.
-  typedef std::pair<int, struct stat> StatResult;
+  /// \brief The set of stat() calls that have been seen.
+  llvm::StringMap<struct stat, llvm::BumpPtrAllocator> StatCalls;
   
-  /// \brief The set of stat() calls that have been
-  llvm::StringMap<StatResult, llvm::BumpPtrAllocator> StatCalls;
-  
-  typedef llvm::StringMap<StatResult, llvm::BumpPtrAllocator>::const_iterator
+  typedef llvm::StringMap<struct stat, llvm::BumpPtrAllocator>::const_iterator
   iterator;
   
   iterator begin() const { return StatCalls.begin(); }

Modified: cfe/trunk/lib/Basic/FileSystemStatCache.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileSystemStatCache.cpp?rev=120031&r1=120030&r2=120031&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileSystemStatCache.cpp (original)
+++ cfe/trunk/lib/Basic/FileSystemStatCache.cpp Tue Nov 23 13:28:12 2010
@@ -34,7 +34,7 @@
   
   // Cache file 'stat' results and directories with absolutely paths.
   if (!S_ISDIR(StatBuf.st_mode) || llvm::sys::Path(Path).isAbsolute())
-    StatCalls[Path] = StatResult(Result, StatBuf);
+    StatCalls[Path] = StatBuf;
   
   return Result;
 }

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=120031&r1=120030&r2=120031&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Nov 23 13:28:12 2010
@@ -1005,7 +1005,6 @@
 
 class ASTStatData {
 public:
-  const bool hasStat;
   const ino_t ino;
   const dev_t dev;
   const mode_t mode;
@@ -1013,10 +1012,7 @@
   const off_t size;
 
   ASTStatData(ino_t i, dev_t d, mode_t mo, time_t m, off_t s)
-  : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {}
-
-  ASTStatData()
-    : hasStat(false), ino(0), dev(0), mode(0), mtime(0), size(0) {}
+    : ino(i), dev(d), mode(mo), mtime(m), size(s) {}
 };
 
 class ASTStatLookupTrait {
@@ -1051,9 +1047,6 @@
                             unsigned /*DataLen*/) {
     using namespace clang::io;
 
-    if (*d++ == 1)
-      return data_type();
-
     ino_t ino = (ino_t) ReadUnalignedLE32(d);
     dev_t dev = (dev_t) ReadUnalignedLE32(d);
     mode_t mode = (mode_t) ReadUnalignedLE16(d);
@@ -1073,10 +1066,8 @@
 
   unsigned &NumStatHits, &NumStatMisses;
 public:
-  ASTStatCache(const unsigned char *Buckets,
-               const unsigned char *Base,
-               unsigned &NumStatHits,
-               unsigned &NumStatMisses)
+  ASTStatCache(const unsigned char *Buckets, const unsigned char *Base,
+               unsigned &NumStatHits, unsigned &NumStatMisses)
     : Cache(0), NumStatHits(NumStatHits), NumStatMisses(NumStatMisses) {
     Cache = CacheTy::Create(Buckets, Base);
   }
@@ -1096,9 +1087,6 @@
     ++NumStatHits;
     ASTStatData Data = *I;
 
-    if (!Data.hasStat)
-      return CacheHitMissing;
-
     StatBuf.st_ino = Data.ino;
     StatBuf.st_dev = Data.dev;
     StatBuf.st_mtime = Data.mtime;

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=120031&r1=120030&r2=120031&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Nov 23 13:28:12 2010
@@ -904,8 +904,8 @@
   typedef const char * key_type;
   typedef key_type key_type_ref;
 
-  typedef std::pair<int, struct stat> data_type;
-  typedef const data_type& data_type_ref;
+  typedef struct stat data_type;
+  typedef const data_type &data_type_ref;
 
   static unsigned ComputeHash(const char *path) {
     return llvm::HashString(path);
@@ -916,9 +916,7 @@
                       data_type_ref Data) {
     unsigned StrLen = strlen(path);
     clang::io::Emit16(Out, StrLen);
-    unsigned DataLen = 1; // result value
-    if (Data.first == 0)
-      DataLen += 4 + 4 + 2 + 8 + 8;
+    unsigned DataLen = 4 + 4 + 2 + 8 + 8;
     clang::io::Emit8(Out, DataLen);
     return std::make_pair(StrLen + 1, DataLen);
   }
@@ -927,21 +925,16 @@
     Out.write(path, KeyLen);
   }
 
-  void EmitData(llvm::raw_ostream& Out, key_type_ref,
+  void EmitData(llvm::raw_ostream &Out, key_type_ref,
                 data_type_ref Data, unsigned DataLen) {
     using namespace clang::io;
     uint64_t Start = Out.tell(); (void)Start;
 
-    // Result of stat()
-    Emit8(Out, Data.first? 1 : 0);
-
-    if (Data.first == 0) {
-      Emit32(Out, (uint32_t) Data.second.st_ino);
-      Emit32(Out, (uint32_t) Data.second.st_dev);
-      Emit16(Out, (uint16_t) Data.second.st_mode);
-      Emit64(Out, (uint64_t) Data.second.st_mtime);
-      Emit64(Out, (uint64_t) Data.second.st_size);
-    }
+    Emit32(Out, (uint32_t) Data.st_ino);
+    Emit32(Out, (uint32_t) Data.st_dev);
+    Emit16(Out, (uint16_t) Data.st_mode);
+    Emit64(Out, (uint64_t) Data.st_mtime);
+    Emit64(Out, (uint64_t) Data.st_size);
 
     assert(Out.tell() - Start == DataLen && "Wrong data length");
   }





More information about the cfe-commits mailing list