summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInstance.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ADT] Normalize empty triple componentsPetr Hosek2018-08-081-1/+1
| | | | | | | | | | | | | | | | | LLVM triple normalization is handling "unknown" and empty components differently; for example given "x86_64-unknown-linux-gnu" and "x86_64-linux-gnu" which should be equivalent, triple normalization returns "x86_64-unknown-linux-gnu" and "x86_64--linux-gnu". autoconf's config.sub returns "x86_64-unknown-linux-gnu" for both "x86_64-linux-gnu" and "x86_64-unknown-linux-gnu". This changes the triple normalization to behave the same way, replacing empty triple components with "unknown". This addresses PR37129. Differential Revision: https://reviews.llvm.org/D50219 llvm-svn: 339294
* Remove trailing spaceFangrui Song2018-07-301-19/+19
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Reapply r336660: [Modules] Autoload subdirectory modulemaps with specific ↵Bruno Cardoso Lopes2018-07-181-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | LangOpts Summary: Reproducer and errors: https://bugs.llvm.org/show_bug.cgi?id=37878 lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't find ModuleName in (proper) search paths. This was causing iteration over all files in the search path subdirectories for example "/usr/include/foobar" in bugzilla case. Users don't expect Clang to load modulemaps in subdirectories implicitly, and also the disk access is not cheap. if (AllowExtraModuleMapSearch) true with ObjC with @import ModuleName. Reviewers: rsmith, aprantl, bruno Subscribers: cfe-commits, teemperor, v.g.vassilev Differential Revision: https://reviews.llvm.org/D48367 llvm-svn: 337430
* Revert "[modules] Fix 37878; Autoload subdirectory modulemaps with specific ↵Bruno Cardoso Lopes2018-07-121-10/+5
| | | | | | | | | | | | | | | LangOpts" This reverts commit f40124d4f05ecf4f880cf4e8f26922d861f705f3 / r336660. This change shouldn't be affecting `@import` behavior, but turns out it is: https://ci.swift.org/view/swift-master-next/job/oss-swift-incremental-RA-osx-master-next/2800/consoleFull#-12570166563122a513-f36a-4c87-8ed7-cbc36a1ec144 Working on a reduced testcase for this, reverting in the meantime. rdar://problem/42102222 llvm-svn: 336920
* [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOptsYuka Takahashi2018-07-101-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Reproducer and errors: https://bugs.llvm.org/show_bug.cgi?id=37878 lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't find ModuleName in (proper) search paths. This was causing iteration over all files in the search path subdirectories for example "/usr/include/foobar" in bugzilla case. Users don't expect Clang to load modulemaps in subdirectories implicitly, and also the disk access is not cheap. if (AllowExtraModuleMapSearch) true with ObjC with @import ModuleName. Reviewers: rsmith, aprantl, bruno Subscribers: cfe-commits, teemperor, v.g.vassilev Differential Revision: https://reviews.llvm.org/D48367 llvm-svn: 336660
* [clang-cl, PCH] Implement support for MS-style PCH through headersErich Keane2018-07-051-30/+1
| | | | | | | | | | | | | | | | | | | | | Implement support for MS-style PCH through headers. This enables support for /Yc and /Yu where the through header is either on the command line or included in the source. It replaces the current support the requires the header also be specified with /FI. This change adds a -cc1 option -pch-through-header that is used to either start or stop compilation during PCH create or use. When creating a PCH, the compilation ends after compilation of the through header. When using a PCH, tokens are skipped until after the through header is seen. Patch By: mikerice Differential Revision: https://reviews.llvm.org/D46652 llvm-svn: 336379
* Factor out Clang's desired 8MB stack size constant from the variousRichard Smith2018-07-031-2/+2
| | | | | | places we hardcode it. llvm-svn: 336231
* Improve diagnostics for config mismatches with -fmodule-file.Richard Smith2018-05-241-3/+10
| | | | | | | | Unless the user uses -Wno-module-file-config-mismatch (or -Wno-error=...), allow the AST reader to produce errors describing the nature of the config mismatch. llvm-svn: 333220
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-6/+6
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [clang-cl] Print /showIncludes to stderr, if used in combination with /E, ↵Erich Keane2018-05-041-1/+1
| | | | | | | | | | | | | | | | | /EP or /P This replicates 'cl.exe' behavior and allows for both preprocessor output and dependency information to be extraced with a single compiler invocation. This is especially useful for compiler caching with tools like Mozilla's sccache. See: https://github.com/mozilla/sccache/issues/246 Patch By: fxb Differential Revision: https://reviews.llvm.org/D46394 llvm-svn: 331533
* [Modules] Allow @import to reach submodules in private module mapsBruno Cardoso Lopes2018-05-021-0/+20
| | | | | | | | | | | | | | | | | | | | A @import targeting a top level module from a private module map file (@import Foo_Private), would fail if there's any submodule declaration around (module Foo.SomeSub) in the same private module map. This happens because compileModuleImpl, when building Foo_Private, will start with the private module map and will not parse the public one, which leads to unsuccessful parsing of Foo.SomeSub, since top level Foo was never parsed. Declaring other submodules in the private module map is not common and should usually be avoided, but it shouldn't fail to build. Canonicalize compileModuleImpl to always look at the public module first, so that all necessary information is available when parsing the private one. rdar://problem/39822328 llvm-svn: 331322
* Use export_as for autolinking frameworksBruno Cardoso Lopes2018-04-161-0/+6
| | | | | | | | | | | | | | | | framework module SomeKitCore { ... export_as SomeKit } Given the module above, while generting autolink information during codegen, clang should to emit '-framework SomeKitCore' only if SomeKit was not imported in the relevant TU, otherwise it should use '-framework SomeKit' instead. rdar://problem/38269782 llvm-svn: 330152
* Revert r329684 (and follow-ups 329693, 329714). See discussion on ↵Nico Weber2018-04-101-6/+0
| | | | | | https://reviews.llvm.org/D43578. llvm-svn: 329739
* -ftime-report switch support in Clang.Andrew V. Tischenko2018-04-101-0/+6
| | | | | | | | | | The current support of the feature produces only 2 lines in report: -Some general Code Generation Time; -Total time of Backend Consumer actions. This patch extends Clang time report with new lines related to Preprocessor, Include Filea Search, Parsing, etc. Differential Revision: https://reviews.llvm.org/D43578 llvm-svn: 329684
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [vfs] Don't bail out after a missing -ivfsoverlay fileBen Langmuir2018-03-231-5/+3
| | | | | | | | | | | | | This make -ivfsoverlay behave more like other fatal errors (e.g. missing -include file) by skipping the missing file instead of bailing out of the whole compilation. This makes it possible for libclang to still provide some functionallity as well as to correctly produce the fatal error diagnostic (previously we lost the diagnostic in libclang since there was no TU to tie it to). rdar://33385423 llvm-svn: 328337
* Remove problematic PrettyStackTrace entry added in r328276Jordan Rose2018-03-231-5/+0
| | | | | | | I'm not sure /why/ this is causing issues for libclang, but it is. Unbreak the buildbots since it's already consumed an hour of my time. llvm-svn: 328286
* Sink PrettyDeclStackTrace down to the AST libraryJordan Rose2018-03-231-0/+5
| | | | | | | ...and add some very basic stack trace entries for module building. This would have helped track down rdar://problem/38434694 sooner. llvm-svn: 328276
* [Modules] Honor -fmodule-name when handling private framework modulesBruno Cardoso Lopes2018-03-201-0/+4
| | | | | | | | | | | | | | | | When skipping building the module for a private framework module, LangOpts.CurrentModule isn't enough for implict modules builds; for instance, in case a private module is built while building a public one, LangOpts.CurrentModule doesn't reflect the -fmodule-name being passed down, but instead the module name which triggered the build. Store the actual -fmodule-name in LangOpts.ModuleName and actually check a name was provided during compiler invocation in order to skip building the private module. rdar://problem/38434694 llvm-svn: 328053
* [Modules] Fix remapping from Foo.Private to Foo_Private to happen before ↵Bruno Cardoso Lopes2018-02-121-33/+33
| | | | | | | | | | typo correction Typo correction is the last step here, remapping should come first. rdar://problem/37351970 llvm-svn: 324965
* [Modules] Map missing private submodules from Foo.Private to Foo_PrivateBruno Cardoso Lopes2017-12-221-2/+36
| | | | | | | | | | | | | | In case `@import Foo.Private` fails because the submodule doesn't exist, look for `Foo_Private` (if available) and build/load that module instead. In that process emit a warning and tell the user about the assumption. The intention here is to assist all existing private modules owners (in ObjC and Swift) to migrate to the new `Foo_Private` syntax. rdar://problem/36023940 llvm-svn: 321342
* Driver: hoist the `wchar_t` handling to the driverSaleem Abdulrasool2017-10-061-0/+1
| | | | | | | | | | | | | | | | Move the logic for determining the `wchar_t` type information into the driver. Rather than passing the single bit of information of `-fshort-wchar` indicate to the frontend the desired type of `wchar_t` through a new `-cc1` option of `-fwchar-type` and indicate the signedness through `-f{,no-}signed-wchar`. This replicates the current logic which was spread throughout Basic into the `RenderCharacterOptions`. Most of the changes to the tests are to ensure that the frontend uses the correct type. Add a new test set under `test/Driver/wchar_t.c` to ensure that we calculate the proper types for the various cases. llvm-svn: 315126
* Use the VFS from the CompilerInvocation by defaultRaphael Isemann2017-09-121-3/+7
| | | | | | | | | | | | | | | | | | | | | Summary: The CompilerInstance should create its default VFS from its CompilerInvocation. Right now the user has to manually create the VFS before creating the FileManager even though `-ivfsoverlay file.yaml` was passed via the CompilerInvocation (which is exactly how we worked around this issue in `FrontendAction.cpp` so far). This patch uses the invocation's VFS by default and also tests this behavior now from the point of view of a program that uses the clang API. Reviewers: benlangmuir, v.g.vassilev Reviewed By: v.g.vassilev Subscribers: mgorny, cfe-commits, v.g.vassilev Differential Revision: https://reviews.llvm.org/D37416 llvm-svn: 313049
* Fix ownership of the MemoryBuffer in a FrontendInputFile.Richard Smith2017-09-091-2/+2
| | | | | | | | This fixes a possible crash on certain kinds of corrupted AST file, but checking in an AST file corrupted in just the right way will be a maintenance nightmare because the format changes frequently. llvm-svn: 312851
* [CUDA] When compilation fails, print the compilation mode.Justin Lebar2017-09-071-2/+11
| | | | | | | | | | | | | | | | | | Summary: That is, instead of "1 error generated", we now say "1 error generated when compiling for sm_35". This (partially) solves a usability foogtun wherein e.g. users call a function that's only defined on sm_60 when compiling for sm_35, and they get an unhelpful error message. Reviewers: tra Subscribers: sanjoy, cfe-commits Differential Revision: https://reviews.llvm.org/D37548 llvm-svn: 312736
* [modules] Add ability to specify module name to module file mapping (reapply)Boris Kolpackov2017-08-311-4/+13
| | | | | | | | | | | | | | | | | | | | Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312220
* Revert r312105 [modules] Add ability to specify module name to module file ↵Victor Leschuk2017-08-301-13/+4
| | | | | | | | mapping Looks like it breaks win10 builder. llvm-svn: 312112
* [modules] Add ability to specify module name to module file mappingBoris Kolpackov2017-08-301-4/+13
| | | | | | | | | | | | | | | | | | | | Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312105
* [modules-ts] Omit submodule semantics for TS modulesBoris Kolpackov2017-08-291-2/+17
| | | | | | | | | | | | If a TS module name has more than one component (e.g., foo.bar) then we erroneously activated the submodule semantics when encountering a module declaration in the module implementation unit (e.g., 'module foo.bar;'). Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35678 llvm-svn: 312007
* Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.Nico Weber2017-08-081-2/+8
| | | | | | | | | | | | | | | This helps some tools that do things based on the output's extension. For example, we got reports from users on Windows that have a tool that scan a build output dir (but skip .obj files). The tool would keep the "foo.obj-12345" file open, and then when clang tried to rename the temp file to the final output filename, that would fail. By making the tempfile end in ".obj.tmp", tools like this could now have a rule to ignore .tmp files. This is a less ambitious reland of https://reviews.llvm.org/D36238 https://reviews.llvm.org/D36413 llvm-svn: 310376
* Revert r309984, "Use "foo-12345.o" instead of "foo.o-12345" as temporary ↵NAKAMURA Takumi2017-08-041-6/+2
| | | | | | | | file name." It generates MODULE-XXXXXXXXXXXX-%%%%%%%%.pcm, then GlobalModuleIndex.cpp is confused with the suffix ".pcm" llvm-svn: 310030
* Use "foo-12345.o" instead of "foo.o-12345" as temporary file name.Nico Weber2017-08-031-2/+6
| | | | | | | | | | | | | | This helps some tools that do things based on the output's extension. For example, we got reports from users on Windows that have a tool that scan a build output dir (but skip .obj files). The tool would keep the "foo.obj-12345" file open, and then when clang tried to rename the temp file to the final output filename, that would fail. By making the tempfile end in ".obj", tools like this will now skip the temp files as well. https://reviews.llvm.org/D36238 llvm-svn: 309984
* Teach ASTReader how to read only the Preprocessor state from an AST file, ↵Richard Smith2017-06-291-2/+2
| | | | | | | | | not the ASTContext state. We use this when running a preprocessor-only action on an AST file in order to avoid paying the runtime cost of loading the extra information. llvm-svn: 306760
* [OpenMP] Add support for auxiliary triple specificationGheorghe-Teodor Bercea2017-06-291-2/+3
| | | | | | | | | | | | | | Summary: Device offloading requires the specification of an additional flag containing the triple of the //other// architecture the code is being compiled on if such an architecture exists. If compiling for the host, the auxiliary triple flag will contain the triple describing the device and vice versa. Reviewers: arpith-jacob, sfantao, caomhin, carlo.bertolli, ABataev, Hahnfeld, jlebar, hfinkel, tstellar Reviewed By: Hahnfeld Subscribers: rengolin, cfe-commits Differential Revision: https://reviews.llvm.org/D29339 llvm-svn: 306689
* Track the set of module maps read while building a .pcm file and reload ↵Richard Smith2017-06-291-2/+5
| | | | | | those when preprocessing from that .pcm file. llvm-svn: 306628
* Support non-identifier module names when preprocessing modules.Richard Smith2017-06-191-2/+9
| | | | llvm-svn: 305758
* Add -frewrite-imports flag.Richard Smith2017-06-091-4/+6
| | | | | | | | If specified, when preprocessing, the contents of imported .pcm files will be included in preprocessed output. The resulting preprocessed file can then be compiled standalone without the module sources or .pcm files. llvm-svn: 305116
* Add #pragma clang module build/endbuild pragmas for performing a module buildRichard Smith2017-06-091-69/+165
| | | | | | | | | | | | | | | as part of a compilation. This is intended for two purposes: 1) Writing self-contained test cases for modules: we can now write a single source file test that builds some number of module files on the side and imports them. 2) Debugging / test case reduction. A single-source testcase is much more amenable to reduction, compared to a VFS tarball or .pcm files. llvm-svn: 305101
* Factor out and unify emission of "module is unavailable" diagnostics.Richard Smith2017-06-051-14/+4
| | | | | | Inspired by post-commit review of r304190. llvm-svn: 304728
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+1
| | | | llvm-svn: 304645
* Move functionality for handling module maps as inputs from the -emit-moduleRichard Smith2017-04-281-9/+11
| | | | | | | | | | | | | | | | | | | action to the general FrontendAction infrastructure. This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map compilation. (The -E form is not currently especially useful yet as there's no good way to take the output and use it to actually build a module.) In order to support this, -cc1 now accepts -x <lang>-module-map in all cases where it accepts -x <lang> for a language we can parse (not ir/ast). And for uniformity, we also accept -x <lang>-header for all such languages (we used to reject for cuda and renderscript), and -x <lang>-cpp-output for all such languages (we used to reject for c, cl, and renderscript). (None of these new alternatives are accepted by the driver yet, so no user-visible changes.) llvm-svn: 301610
* Preprocessor: Suppress -Wnonportable-include-path for header mapsDuncan P. N. Exon Smith2017-04-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a file search involves a header map, suppress -Wnonportable-include-path. It's firing lots of false positives for framework authors internally, and it's not trivial to fix. Consider a framework called "Foo" with a main (installed) framework header "Foo/Foo.h". It's atypical for "Foo.h" to actually live inside a directory called "Foo" in the source repository. Instead, the build system generates a header map while building the framework. If Foo.h lives at the top-level of the source repository (common), and the git repo is called ssh://some.url/foo.git, then the header map will have something like: Foo/Foo.h -> /Users/myname/code/foo/Foo.h where "/Users/myname/code/foo" is the clone of ssh://some.url/foo.git. After #import <Foo/Foo.h>, the current implementation of -Wnonportable-include-path will falsely assume that Foo.h was found in a nonportable way, because of the name of the git clone (.../foo/Foo.h). However, that directory name was not involved in the header search at all. This commit adds an extra parameter to Preprocessor::LookupFile and HeaderSearch::LookupFile to track if the search used a header map, making it easy to suppress the warning. Longer term, once we find a way to avoid the false positive, we should turn the warning back on. rdar://problem/28863903 llvm-svn: 301592
* Refactor frontend InputKind to prepare for treating module maps as a ↵Richard Smith2017-04-261-6/+7
| | | | | | | | distinct kind of input. No functionality change intended. llvm-svn: 301442
* [PCH] Attach instance's dependency collectors to PCH external AST sources.Graydon Hoare2017-03-291-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When a PCH is included via -include-pch, clang should treat the current TU as dependent on the sourcefile that the PCH was generated from. This is currently _partly_ accomplished by InitializePreprocessor calling AddImplicitIncludePCH to synthesize an implicit #include of the sourcefile, into the preprocessor's Predefines buffer. For FrontendActions such as PreprocessOnlyAction (which is, curiously, what the driver winds up running one of in response to a plain clang -M) this is sufficient: the preprocessor cranks over its Predefines and emits a dependency reference to the initial sourcefile. For other FrontendActions (for example -emit-obj or -fsyntax-only) the Predefines buffer is reset to the suggested predefines buffer from the PCH, so the dependency edge is lost. The result is that clang emits a .d file in those cases that lacks a reference to the .h file responsible for the input (and in Swift's case, our .swiftdeps file winds up not including a reference to the source file for a PCH bridging header.) This patch fixes the problem by taking a different tack: ignoring the Predefines buffer (which seems a bit like a hack anyways) and directly attaching the CompilerInstance's DependencyCollectors (and legacy DependencyFileGenerator) to the ASTReader for the external AST. This approach is similar to the one chosen in earlier consultation with Bruno and Ben, and I think it's the least-bad solution, given several options. Reviewers: bruno, benlangmuir, doug.gregor Reviewed By: bruno, doug.gregor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31378 llvm-svn: 299009
* Move setting of LangOpts based on target flags out of CompilerInstanceEric Christopher2017-03-221-6/+0
| | | | | | | | | and into TargetInfo::adjust so that it gets called in more places throughout the compiler (AST serialization in particular). Should fix PPC modules after removing of faltivec. llvm-svn: 298487
* Remove the -faltivec alias option and replace it with -maltivec everywhere.Eric Christopher2017-03-211-0/+6
| | | | | | | | | | | The alias was only ever used on darwin and had some issues there, and isn't used in practice much. Also fixes a problem with -mno-altivec not turning off -maltivec. Also add a diagnostic for faltivec/fno-altivec that directs users to use maltivec options and include the altivec.h file explicitly. llvm-svn: 298449
* Reapply "Modules: Cache PCMs in memory and avoid a use-after-free"Duncan P. N. Exon Smith2017-03-201-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit r298185, effectively reapplying r298165, after fixing the new unit tests (PR32338). The memory buffer generator doesn't null-terminate the MemoryBuffer it creates; this version of the commit informs getMemBuffer about that to avoid the assert. Original commit message follows: ---- 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: 298278
* Revert "Modules: Cache PCMs in memory and avoid a use-after-free"Renato Golin2017-03-181-17/+6
| | | | | | This reverts commit r298165, as it broke the ARM builds. llvm-svn: 298185
* [Modules] In case of lock timeout, fallback and build moduleBruno Cardoso Lopes2017-03-181-5/+12
| | | | | | | | | | | | | | Duncan's r298165 introduced the PCMCache mechanism, which guarantees that locks aren't necessary anymore for correctness but only for performance, by avoiding building it twice when possible. Change the logic to avoid an error but actually build the module in case the timeout happens. Instead of an error, still emit a remark for debugging purposes. rdar://problem/30297862 llvm-svn: 298175
* Modules: Cache PCMs in memory and avoid a use-after-freeDuncan P. N. Exon Smith2017-03-171-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud