summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ModuleManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl2015-02-201-4/+5
| | | | | | | | | | | This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 llvm-svn: 230044
* [modules] When explicitly importing a module, it's fine for the imported moduleRichard Smith2014-11-211-0/+7
| | | | | | | | to be newer than we were expecting. That happens if .pcm's get moved between file systems during a distributed build. (It's still not OK for them to actually be different, though, so we still check the size and signature matches.) llvm-svn: 222507
* Check module signature when the module has already been loadedBen Langmuir2014-11-081-7/+13
| | | | | | | | | | We may need to verify the signature on subsequent imports as well, just like we verify the size/modtime: @import A; @import B; // imports A @import C; // imports A llvm-svn: 221569
* Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer2014-10-261-13/+12
| | | | | | | This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
* [Modules] Free modules that failed signature verification.Benjamin Kramer2014-10-241-0/+1
| | | | | | The control flow and ownership is weird enough so unique_ptr doesn't help here :( llvm-svn: 220569
* Add a "signature" to AST files to verify that they haven't changedBen Langmuir2014-10-231-0/+18
| | | | | | | | | | | | | | | | | | | | | 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
* [modules] Initial support for explicitly loading .pcm files.Richard Smith2014-10-221-1/+1
| | | | | | | | | | | | | | | Implicit module builds are not well-suited to a lot of build systems. In particular, they fare badly in distributed build systems, and they lead to build artifacts that are not tracked as part of the usual dependency management process. This change allows explicitly-built module files (which are already supported through the -emit-module flag) to be explicitly loaded into a build, allowing build systems to opt to manage module builds and dependencies themselves. This is only the first step in supporting such configurations, and it should be considered experimental and subject to change or removal for now. llvm-svn: 220359
* Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola2014-08-261-3/+3
| | | | llvm-svn: 216476
* Store std::unique_ptr in InMemoryBuffers. NFC.Rafael Espindola2014-08-181-11/+12
| | | | llvm-svn: 215928
* Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid ↵Craig Topper2014-08-171-1/+1
| | | | | | needing to mention the size. llvm-svn: 215869
* Update for llvm api change.Rafael Espindola2014-07-061-1/+5
| | | | llvm-svn: 212408
* Avoid invalidating successfully loaded module filesBen Langmuir2014-06-201-22/+17
| | | | | | | | | | | | | | | | | Successfully loaded module files may be referenced in other ModuleManagers, so don't invalidate them. Two related things are fixed: 1) I thought the last module in the manager was always the one that failed, but it isn't. So check explicitly against the list of vetted modules from ReadASTCore. 2) We now keep the file descriptor of pcm file open, which avoids the possibility of having two different pcms for the same module loaded when building in parallel with headers being modified during a build. <rdar://problem/16835846> llvm-svn: 211330
* Include system_error directly.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210802
* Replace llvm::error_code with std::error_code.Rafael Espindola2014-06-121-1/+1
| | | | llvm-svn: 210780
* Invalidate the file system cache entries for files that may rebuildBen Langmuir2014-05-301-5/+21
| | | | | | | | | | | | | | | | | | | | | | This reapplies r209910 with a fix for the assertion failures hit on the buildbots. original commit message: I thought we could get away without this, but it means that the FileEntry objects actually refer to the wrong files, since pcms are not updated inplace, they are atomically renamed into place after compiling a module. So we are close to the original behaviour of invalidating the cache for all modules being removed, but now we should only invalidate the ones that depend on whichever module failed to load. Unfortunately I haven't come up with a new test that didn't require a race between parallel invocations of clang. <rdar://problem/17038180> llvm-svn: 209922
* Revert "Invalidate the file system cache entries for files that may rebuild"Ben Langmuir2014-05-301-18/+5
| | | | | | This reverts commit r209910, which is breaking some of the bots. llvm-svn: 209911
* Invalidate the file system cache entries for files that may rebuildBen Langmuir2014-05-301-5/+18
| | | | | | | | | | | | | | | | | | I thought we could get away without this, but it means that the FileEntry objects actually refer to the wrong files, since pcms are not updated inplace, they are atomically renamed into place after compiling a module. So we are close to the original behaviour of invalidating the cache for all modules being removed, but now we should only invalidate the ones that depend on whichever module failed to load. Unfortunately I haven't come up with a new test that didn't require a race between parallel invocations of clang. <rdar://problem/17038180> llvm-svn: 209910
* [C++11] Use 'nullptr'. Serialization edition.Craig Topper2014-05-221-8/+8
| | | | llvm-svn: 209392
* Speculative fix for Windows buildbot after r209138Ben Langmuir2014-05-201-0/+5
| | | | | | | | | It appears that Windows doesn't like renaming over open files, which we do in clearOutputFiles. The file being compiled should be safe to removed, but this isn't very satisfying - we don't want to manually manage the lifetime of files we cannot prove have no references. llvm-svn: 209195
* Don't refresh stat() info for pcm filesBen Langmuir2014-05-191-13/+1
| | | | | | | | Follow-up fix for 209138. Actually, since we already have this file open, we don't want to refresh the stat() info, since that might be newer than what we have open (bad!). llvm-svn: 209143
* Fix use-after-free and spurious error during module loadBen Langmuir2014-05-191-2/+13
| | | | | | | | | | | | | | FileManager::invalidateCache is not safe to call when there may be existing references to the file. What module load failure needs is to refresh so stale stat() info isn't stored. This may be the last user of invalidateCache; I'll take a look and remove it if possible in a future commit. This caused a use-after-free error as well as a spurious error message that a module was "found in both 'X.pcm' and 'X.pcm'" in some cases. llvm-svn: 209138
* Fix a use-after-free bug I recently introduced in lookupModuleFileBen Langmuir2014-05-041-4/+3
| | | | llvm-svn: 207932
* Avoid a potential race between stat() and open() of ASTFileBen Langmuir2014-05-011-1/+5
| | | | | | | | We need to open an ASTFile while checking its expected size and modification time, or another clang instance can modify the file between the stat() and the open(). llvm-svn: 207735
* Allow multiple modules with the same name to coexist in the module cacheBen Langmuir2014-04-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [C++11] Remove a now unnecessary use of std::function for a remove_ifChandler Carruth2014-03-031-4/+3
| | | | | | | | predicate. The wrapper used by SetVector was erroneously requiring an adaptable predicate. It has been fixed and we really don't want to require an indirect call for every predicate evaluation. llvm-svn: 202744
* [C++11] Replace verbose functors with succinct lambdasBenjamin Kramer2014-03-011-17/+3
| | | | | | No functionality change. llvm-svn: 202590
* Recommit virtual file systemBen Langmuir2014-02-201-1/+1
| | | | | | | | | | | Previously reverted in r201755 due to causing an assertion failure. I've removed the offending assertion, and taught the CompilerInstance to create a default virtual file system inside createFileManager. In the future, we should be able to reach into the CompilerInvocation to customize this behaviour without breaking clients that don't care. llvm-svn: 201818
* Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka2014-02-201-1/+1
| | | | | | | | | | assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
* Initial implementation of virtual file systemBen Langmuir2014-02-191-1/+1
| | | | | | | | | | | | This adds the minimum virtual file system support to start migrating FileManager onto the VFS. Originally discussed here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html Differential Revision: http://llvm-reviews.chandlerc.com/D2745 llvm-svn: 201618
* Add an option to allow Clang verify source files for a module only once duringDmitri Gribenko2014-02-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the build When Clang loads the module, it verifies the user source files that the module was built from. If any file was changed, the module is rebuilt. There are two problems with this: 1. correctness: we don't verify system files (there are too many of them, and stat'ing all of them would take a lot of time); 2. performance: the same module file is verified again and again during a single build. This change allows the build system to optimize source file verification. The idea is based on the fact that while the project is being built, the source files don't change. This allows us to verify the module only once during a single build session. The build system passes a flag, -fbuild-session-timestamp=, to inform Clang of the time when the build started. The build system also requests to enable this feature by passing -fmodules-validate-once-per-build-session. If these flags are not passed, the behavior is not changed. When Clang verifies the module the first time, it writes out a timestamp file. Then, when Clang loads the module the second time, it finds a timestamp file, so it can compare the verification timestamp of the module with the time when the build started. If the verification timestamp is too old, the module is verified again, and the timestamp file is updated. llvm-svn: 201224
* Add a bit more info to modules fatal error.Eli Friedman2013-09-051-2/+4
| | | | | | | Just a minor tweak to make it easier to track down the cause of fatal errors with modules. llvm-svn: 190108
* This wasn't headers, just missing namespaces.Benjamin Kramer2013-08-241-1/+0
| | | | | | /me bows head in shame. llvm-svn: 189172
* Add missing includes.Benjamin Kramer2013-08-241-1/+2
| | | | llvm-svn: 189171
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-2/+1
| | | | | | No functionality change intended. llvm-svn: 189112
* Include Path.h instead of PathV2.h.Rafael Espindola2013-06-111-1/+1
| | | | | | I am about to move PathV2.h to Path.h. llvm-svn: 183795
* <rdar://problem/13509689> Introduce -module-file-info option that provides ↵Douglas Gregor2013-03-271-1/+13
| | | | | | | | | | | information about a particular module file. This option can be useful for end users who want to know why they ended up with a ton of different variants of the "std" module in their module cache. This problem should go away over time, as we reduce the need for module variants, but it will never go away entirely. llvm-svn: 178148
* <rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex ↵Douglas Gregor2013-03-221-47/+18
| | | | | | | | | | | | | | 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
* Remove unused variable.Benjamin Kramer2013-03-211-3/+0
| | | | llvm-svn: 177657
* <rdar://problem/13363214> Eliminate race condition between module rebuild ↵Douglas Gregor2013-03-191-26/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Never cache the result of a module file lookup.Douglas Gregor2013-02-081-3/+6
| | | | llvm-svn: 174744
* Eliminate memory allocation from most invocations ofDouglas Gregor2013-01-281-13/+38
| | | | | | | | | | ModuleManager::visit() by keeping a free list of the two data structures used to store state (a preallocated stack and a visitation number vector). Improves -fsyntax-only performance for my modules test case by 2.8%. Modules has pulled ahead by almost 10% with the global module index. llvm-svn: 173692
* Improve coordination between the module manager and the global moduleDouglas Gregor2013-01-251-5/+51
| | | | | | | | | 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
* Optimize ModuleManager::visit() by precomputing the visitation orderDouglas Gregor2013-01-251-65/+82
| | | | | | | | | | and limiting ourselves to two memory allocations. 10% speedup in -fsyntax-only time for modules. With this change, we can actually see some performance different from the global module index, but it's still about 1%. llvm-svn: 173512
* Implement the reader of the global module index and wire it into theDouglas Gregor2013-01-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | 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
* Give ModuleFiles an index, so that we can use indexed vectors ratherDouglas Gregor2013-01-211-20/+30
| | | | | | | than DenseMaps and SmallPtrSets for module-visitation data. ~2.6% speedup for modules. llvm-svn: 173081
* Actually keep track of the source locations at which particular moduleDouglas Gregor2012-11-301-4/+8
| | | | | | files are loaded. llvm-svn: 169027
* When loading a module fails because it is out of date, rebuild thatDouglas Gregor2012-11-071-0/+39
| | | | | | module in place. <rdar://problem/10138913> llvm-svn: 167539
* Set the file entry for a Module* that was created during deserializationArgyrios Kyrtzidis2012-10-031-1/+2
| | | | | | of a module file. llvm-svn: 165086
* Optimize unqualified/global name lookup in modules by introducing aDouglas Gregor2012-01-181-2/+3
| | | | | | | | | | generational scheme for identifiers that avoids searching the hash tables of a given module more than once for a given identifier. Previously, loading any new module invalidated all of the previous lookup results for all identifiers, causing us to perform the lookups repeatedly. llvm-svn: 148412
* Promote ModuleMap::Module to a namespace-scope class in the BasicDouglas Gregor2011-11-301-25/+25
| | | | | | | | | library, since modules cut across all of the libraries. Rename serialization::Module to serialization::ModuleFile to side-step the annoying naming conflict. Prune a bunch of ModuleMap.h includes that are no longer needed (most files only needed the Module type). llvm-svn: 145538
OpenPOWER on IntegriCloud