aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/GlobalModuleIndex.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-11-12Simplify code a bit by passing StreamFile to the BitstreamCursor constructor.Rafael Espindola1-2/+1
llvm-svn: 221784
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-5/+3
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-10-23Add a "signature" to AST files to verify that they haven't changedBen Langmuir1-0/+4
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs) is not stable, it is not safe to load an AST file that depends on another AST file that has been rebuilt since the importer was built, even if "nothing changed". We previously used size and modtime to check this, but I've seen cases where a module rebuilt quickly enough to foil this check and caused very hard to debug build errors. To save cycles when we're loading the AST, we just generate a random nonce value and check that it hasn't changed when we load an imported module, rather than actually hash the whole file. This is slightly complicated by the fact that we need to verify the signature inside addModule, since we might otherwise consider that a mdoule is "OutOfDate" when really it is the importer that is out of date. I didn't see any regressions in module load time after this change. llvm-svn: 220493
2014-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-2/+3
llvm-svn: 216476
2014-08-11unique_ptr-ify the MemoryBuffer parameter of GlobalModuleIndexDavid Blaikie1-5/+4
llvm-svn: 215376
2014-07-06Update for llvm api change.Rafael Espindola1-2/+4
llvm-svn: 212408
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola1-1/+1
llvm-svn: 210780
2014-05-31There is no std::errc:success, remove the llvm one.Rafael Espindola1-2/+1
llvm-svn: 209959
2014-05-22[C++11] Use 'nullptr'. Serialization edition.Craig Topper1-3/+3
llvm-svn: 209392
2014-04-25Fix leak of GlobalModuleIndex::IdentifierIndex, found by LSan.Nico Weber1-1/+3
llvm-svn: 207262
2014-04-18Teach users of OnDiskHashTable to define hash_value and offset typesJustin Bogner1-2/+6
This paves the way to making OnDiskHashTable work with hashes that are not 32 bits wide and to making OnDiskHashTable work very large hash tables. The LLVM change to use these types is upcoming. llvm-svn: 206640
2014-04-18Remove OnDiskHashTable.h, since it's been moved to llvmJustin Bogner1-6/+5
llvm-svn: 206637
2014-04-17Revised per Dmitri's comments. My first exposure to range-based for loops, ↵John Thompson1-1/+1
thanks! llvm-svn: 206483
2014-04-17Revised per Dmitri's comments. My first exposure to range-based for loops, ↵John Thompson1-10/+8
thanks! llvm-svn: 206474
2014-04-16Added dump method for global module index.John Thompson1-0/+15
llvm-svn: 206418
2014-04-14Allow multiple modules with the same name to coexist in the module cacheBen Langmuir1-2/+8
To differentiate between two modules with the same name, we will consider the path the module map file that they are defined by* part of the ‘key’ for looking up the precompiled module (pcm file). Specifically, this patch renames the precompiled module (pcm) files from cache-path/<module hash>/Foo.pcm to cache-path/<module hash>/Foo-<hash of module map path>.pcm In addition, I’ve taught the ASTReader to re-resolve the names of imported modules during module loading so that if the header search context changes between when a module was originally built and when it is loaded we can rebuild it if necessary. For example, if module A imports module B first time: clang -I /path/to/A -I /path/to/B ... second time: clang -I /path/to/A -I /different/path/to/B ... will now rebuild A as expected. * in the case of inferred modules, we use the module map file that allowed the inference, not the __inferred_module.map file, since the inferred file path is the same for every inferred module. llvm-svn: 206201
2014-04-14OnDiskHashTable: Make the iterable version separate.Justin Bogner1-6/+9
Currently the on disk hash table's key_iterator and data_iterator make the assumption that the table data starts exactly four bytes after the base of the table. This happens to be true for all of the tables we currently iterate over, but not for all of the OnDiskHashTables we currently use. For example, key_ and data_iterator would iterate over meaningless data if they were used on the hash tables in PTHLexer. We make the API safer by breaking this into two types. One doesn't have the iterators, and the other must be told where the payload starts. llvm-svn: 206189
2014-03-28Reapply "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-7/+7
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205062
2014-03-28Reapply "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-4/+8
Committed this by accident before it was done last time. Original message: Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205061
2014-03-28Revert "OnDiskHashTable: Use Endian.h to read little endian ostreams"Justin Bogner1-7/+7
This reverts commit r205045. llvm-svn: 205048
2014-03-28Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"Justin Bogner1-8/+4
This reverts commit r205044. llvm-svn: 205047
2014-03-28OnDiskHashTable: Use Endian.h to read little endian ostreamsJustin Bogner1-7/+7
Rather than rolling our own functions to read little endian data from a buffer, we can use the support in llvm's Endian.h. No functional change. llvm-svn: 205045
2014-03-28OnDiskHashTable: Use EndianStream.h to write little endian ostreamsJustin Bogner1-4/+8
Rather than rolling our own functions to write little endian data to an ostream, we can use the support in llvm's EndianStream.h. No functional change. llvm-svn: 205044
2014-03-13[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper1-1/+1
class. llvm-svn: 203746
2014-03-07Replace OwningPtr with std::unique_ptr.Ahmed Charles1-6/+6
This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
2014-03-07Change OwningPtr::take() to OwningPtr::release().Ahmed Charles1-2/+3
This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
2014-01-10Use the simpler version of llvm::sys::fs::remove when possible.Rafael Espindola1-3/+2
llvm-svn: 198957
2013-10-25I am about to change llvm::MemoryBuffer::getFile take take a Twine. ChangeRafael Espindola1-1/+2
clang first so that the build still works. llvm-svn: 193428
2013-07-05Use llvm::sys::fs::createUniqueFile.Rafael Espindola1-1/+2
Include a test that clang now produces output files with permissions matching the umask. llvm-svn: 185727
2013-06-11Include Path.h instead of PathV2.h.Rafael Espindola1-1/+1
I am about to move PathV2.h to Path.h. llvm-svn: 183795
2013-04-17[Modules] Use global index to improve typo correction performanceArgyrios Kyrtzidis1-0/+31
Typo correction for an unqualified name needs to walk through all of the identifier tables of all modules. When we have a global index, just walk its identifier table only. rdar://13425732 llvm-svn: 179730
2013-03-22<rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex ↵Douglas Gregor1-65/+31
interaction to eliminate a pile of extraneous stats(). The refactoring in r177367 introduced a serious performance bug where the "lazy" resolution of module file names in the global module index to actual module file entries in the module manager would perform repeated negative stats(). The new interaction requires the module manager to inform the global module index when a module file has been loaded, eliminating the extraneous stat()s and a bunch of bookkeeping on both sides. llvm-svn: 177750
2013-03-19<rdar://problem/13363214> Eliminate race condition between module rebuild ↵Douglas Gregor1-133/+104
and the global module index. The global module index was querying the file manager for each of the module files it knows about at load time, to prune out any out-of-date information. The file manager would then cache the results of the stat() falls used to find that module file. Later, the same translation unit could end up trying to import one of the module files that had previously been ignored by the module cache, but after some other Clang instance rebuilt the module file to bring it up-to-date. The stale stat() results in the file manager would trigger a second rebuild of the already-up-to-date module, causing failures down the line. The global module index now lazily resolves its module file references to actual AST reader module files only after the module file has been loaded, eliminating the stat-caching race. Moreover, the AST reader can communicate to its caller that a module file is missing (rather than simply being out-of-date), allowing us to simplify the module-loading logic and allowing the compiler to recover if a dependent module file ends up getting deleted. llvm-svn: 177367
2013-02-08Never cache the result of a module file lookup.Douglas Gregor1-2/+5
llvm-svn: 174744
2013-02-06Eliminate a race condition with the global module index.Douglas Gregor1-1/+2
Essentially, a module file on disk could change size between the time we stat() it and the time we open it, and we need to be robust against such a problem. llvm-svn: 174529
2013-01-28ASTReader and profiling statistics indicate that implementing a methodDouglas Gregor1-4/+0
pool in the global module index is not worthwhile. Update comments to limit the scope of the global module index to identifiers. llvm-svn: 173705
2013-01-25Improve coordination between the module manager and the global moduleDouglas Gregor1-26/+5
index, optimizing the operation that skips lookup in modules where we know the identifier will not be found. This makes the global module index optimization actually useful, providing an 8.5% speedup over modules without the global module index for -fsyntax-only. llvm-svn: 173529
2013-01-25Serialization/GlobalModuleIndex.cpp: Fixup r173405, <cstdio>NAKAMURA Takumi1-0/+1
llvm-svn: 173408
2013-01-25Implement the reader of the global module index and wire it into theDouglas Gregor1-17/+387
AST reader. The global module index tracks all of the identifiers known to a set of module files. Lookup of those identifiers looks first in the global module index, which returns the set of module files in which that identifier can be found. The AST reader only needs to look into those module files and any module files not known to the global index (e.g., because they were (re)built after the global index), reducing the number of on-disk hash tables to visit. For an example source I'm looking at, we go from 237844 total identifier lookups into on-disk hash tables down to 126817. Unfortunately, this does not translate into a performance advantage. At best, it's a wash once the global module index has been built, but that's ignore the cost of building the global module index (which is itself fairly large). Profiles show that the global module index code is far less efficient than it should be; optimizing it might give enough of an advantage to justify its continued inclusion. llvm-svn: 173405
2013-01-24clang/GlobalModuleIndex: Don't open the same file twice. Use ↵NAKAMURA Takumi1-3/+1
raw_fd_ostream(fd, ...) instead. FIXME: PathV2::unique_file() is assumed to open the file with binary mode on win32. llvm-svn: 173330
2013-01-23Fix for case-sensitive file systems. UghDouglas Gregor1-1/+1
llvm-svn: 173303
2013-01-23Implement the writer side of the global module index. Douglas Gregor1-0/+535
The global module index is a "global" index for all of the module files within a particular subdirectory in the module cache, which keeps track of all of the "interesting" identifiers and selectors known in each of the module files. One can perform a fast lookup in the index to determine which module files will have more information about entities with a particular name/selector. This information can help eliminate redundant lookups into module files (a serious performance problem) and help with creating auto-import/auto-include Fix-Its. The global module index is created or updated at the end of a translation unit that has triggered a (re)build of a module by scraping all of the .pcm files out of the module cache subdirectory, so it catches everything. As with module rebuilds, we use the file system's atomicity to synchronize. llvm-svn: 173301