llvm-project/clang/test
Duncan P. N. Exon Smith 079c40e886 Modules: Cache PCMs in memory and avoid a use-after-free
Clang's internal build system for implicit modules uses lock files to
ensure that after a process writes a PCM it will read the same one back
in (without contention from other -cc1 commands).  Since PCMs are read
from disk repeatedly while invalidating, building, and importing, the
lock is not released quickly.  Furthermore, the LockFileManager is not
robust in every environment.  Other -cc1 commands can stall until
timeout (after about eight minutes).

This commit changes the lock file from being necessary for correctness
to a (possibly dubious) performance hack.  The remaining benefit is to
reduce duplicate work in competing -cc1 commands which depend on the
same module.  Follow-up commits will change the internal build system to
continue after a timeout, and reduce the timeout.  Perhaps we should
reconsider blocking at all.

This also fixes a use-after-free, when one part of a compilation
validates a PCM and starts using it, and another tries to swap out the
PCM for something new.

The PCMCache is a new type called MemoryBufferCache, which saves memory
buffers based on their filename.  Its ownership is shared by the
CompilerInstance and ModuleManager.

  - The ModuleManager stores PCMs there that it loads from disk, never
    touching the disk if the cache is hot.

  - When modules fail to validate, they're removed from the cache.

  - When a CompilerInstance is spawned to build a new module, each
    already-loaded PCM is assumed to be valid, and is frozen to avoid
    the use-after-free.

  - Any newly-built module is written directly to the cache to avoid the
    round-trip to the filesystem, making lock files unnecessary for
    correctness.

Original patch by Manman Ren; most testcases by Adrian Prantl!

llvm-svn: 298165
2017-03-17 22:55:13 +00:00
..
ARCMT [test] Port clang tests to canonicalized booleans 2017-01-25 13:11:45 +00:00
ASTMerge [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands 2017-03-13 15:32:24 +00:00
Analysis [analyzer] Fix a rare crash for valist check. 2017-03-13 12:48:26 +00:00
CXX Implement DR 373 "Lookup on namespace qualified name in using-directive" 2017-03-17 21:41:20 +00:00
CodeCompletion [Preprocessor] Fix incorrect token caching that occurs when lexing _Pragma 2017-02-24 17:45:16 +00:00
CodeGen [AVX-512] Fix test cases that were using the builtins directly without typecasts instead of the intrinsic header. 2017-03-17 05:59:22 +00:00
CodeGenCUDA [CodeGen] [CUDA] Add the ability set default attrs on functions in linked modules. 2017-01-25 21:29:48 +00:00
CodeGenCXX Retry: [ubsan] Detect UB loads from bitfields 2017-03-09 16:06:27 +00:00
CodeGenCoroutines [coroutines] Build and pass coroutine_handle to await_suspend 2017-03-09 03:09:43 +00:00
CodeGenObjC [ubsan] Use the nicer nullability diagnostic handlers 2017-03-14 16:48:29 +00:00
CodeGenObjCXX Represent pass_object_size attrs in ExtParameterInfo 2017-02-24 02:49:47 +00:00
CodeGenOpenCL AMDGPU: Make 0 the private nullptr value 2017-03-13 19:47:53 +00:00
Coverage Handle StaticAssertDecl in DeclContextPrinter 2017-01-03 12:16:02 +00:00
CoverageMapping Suppress uninteresting warnings in test/CoverageMapping, NFC. 2017-02-25 07:05:41 +00:00
Driver Fix up testcase to: 2017-03-15 23:41:58 +00:00
FixIt [Sema] Improve the error diagnostic for dot destructor calls on pointer objects 2017-01-20 15:38:58 +00:00
Format clang/test/Format/inplace.cpp: Avoid using wildcard. 2017-02-28 10:05:56 +00:00
Frontend Add -iframeworkwithsysroot compiler option 2017-03-13 11:17:41 +00:00
Headers [Headers] Reapply: Add #include_next for tgmath.h on Darwin 2017-03-16 23:19:00 +00:00
Import Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
Index [index/AST] Add references for ObjC getter=/setter= property attributes and related property getter/setter role fixes 2017-03-16 18:25:40 +00:00
Integration
Layout Print nested name specifiers for typedefs and type aliases 2017-03-10 15:04:58 +00:00
Lexer [c++1z] Mark constexpr lambdas as done on status page and start advertising 2017-02-21 23:58:29 +00:00
Misc Disable warning about MSVC not found. 2017-03-15 16:35:13 +00:00
Modules Modules: Cache PCMs in memory and avoid a use-after-free 2017-03-17 22:55:13 +00:00
OpenMP [test] Unbreak OpenMP/linking.c with arch-specific libdir 2017-03-08 09:07:33 +00:00
PCH [PCH] Avoid VarDecl emission attempt if no owning module avaiable 2017-03-01 19:18:42 +00:00
Parser Introduce an 'external_source_symbol' attribute that describes the origin 2017-03-01 18:06:25 +00:00
Preprocessor Add a small test for __STRUCT_PARM_ALIGN__ for ppc64 darwin. 2017-03-16 22:31:07 +00:00
Profile Weaken test/Profile/c-ternary.c 2017-02-25 07:21:23 +00:00
Rewriter [test] Port clang tests to canonicalized booleans 2017-01-25 13:11:45 +00:00
Sema Fix crash with interrupt attribute on ARM. 2017-03-14 00:18:29 +00:00
SemaCUDA [CUDA] Let NVPTX inherit the host's calling conventions. 2017-01-05 16:53:38 +00:00
SemaCXX Warn on enum assignment to bitfields that can't fit all values 2017-03-14 18:01:02 +00:00
SemaObjC [ObjC][Sema] Avoid ARC performSelector error for 'self' selector 2017-03-16 16:36:11 +00:00
SemaObjCXX Print nested name specifiers for typedefs and type aliases 2017-03-10 15:04:58 +00:00
SemaOpenCL [OpenCL] Implement as_type operator as alias of __builtin_astype. 2017-03-16 12:15:10 +00:00
SemaTemplate Print nested name specifiers for typedefs and type aliases 2017-03-10 15:04:58 +00:00
TableGen
Tooling [test] Port clang tests to canonicalized booleans 2017-01-25 13:11:45 +00:00
Unit [test] Extend llvm_shlib_dir fix to unittests 2016-12-15 20:31:08 +00:00
VFS Don't diagnose non-modular includes when we are not compiling a module. 2016-08-26 17:16:46 +00:00
.clang-format
CMakeLists.txt Re-apply r292662, "IRGen: Start using the WriteThinLTOBitcode pass." 2017-01-26 23:51:50 +00:00
TestRunner.sh
cxx-sections.data
lit.cfg [Driver] Add flag to request arch-specific-subdir in -rpath 2017-03-14 16:58:07 +00:00
lit.site.cfg.in [test] Port clang tests to canonicalized booleans 2017-01-25 13:11:45 +00:00
make_test_dirs.pl