aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks1-6/+6
(#66295) This will make it easy for callers to see issues with and fix up calls to createTargetMachine after a future change to the params of TargetMachine. This matches other nearby enums. For downstream users, this should be a fairly straightforward replacement, e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive or s/CGFT_/CodeGenFileType::
2023-09-14Reland "[clang] Add experimental option to omit the RTTI component from the ↵Leonard Chan1-0/+8
vtable when -fno-rtti is used" This reverts commit 070493ddbd9473499d6f00ca62bc6aa92808ed79 (and relands the original change). This removes a test run that makes an assumption of RTTI being on by default for a given target.
2023-09-13Revert "Revert "Revert "[clang] Add experimental option to omit the RTTI ↵Douglas Yung1-8/+0
component from the vtable when -fno-rtti is used""" This reverts commit e16474ba2cba8fa69b413a83852d06c93155f8c9. This change is still causing a test failure on a bot: https://lab.llvm.org/buildbot/#/builders/139/builds/49666
2023-09-14Revert "Revert "[clang] Add experimental option to omit the RTTI component ↵Leonard Chan1-0/+8
from the vtable when -fno-rtti is used"" This attempts to reland 6385c1df919f237d4149fabf542a158f61010bf8 but with a fix for the test failure.
2023-09-13Revert "[clang] Add experimental option to omit the RTTI component from the ↵Leonard Chan1-8/+0
vtable when -fno-rtti is used" This reverts commit 6385c1df919f237d4149fabf542a158f61010bf8. Reverting since this broke a windows builder: https://lab.llvm.org/buildbot/#/builders/216/builds/27252.
2023-09-13[clang] Add experimental option to omit the RTTI component from the vtable ↵Leonard Chan1-0/+8
when -fno-rtti is used For programs that don't use RTTI, the rtti component is just replaced with a zero. This way, vtables that don't use RTTI can still cooperate with vtables that use RTTI since offset calculations on the ABI level would still work. However, if throughout your whole program you don't use RTTI at all (such as the embedded case), then this is just an unused pointer-sized component that's wasting space. This adds an experimental option for removing the RTTI component from the vtable. Some notes: - This is only allowed when RTTI is disabled, so we don't have to worry about things like `typeid` or `dynamic_cast`. - This is a "use at your own risk" since, similar to relative vtables, everything must be compiled with this since it's an ABI breakage. That is, a program compiled with this is not guaranteed to work with a program compiled without this, even if RTTI is disabled for both programs. Note that this is a completely different ABI flavor orthogonal to the relative-vtables ABI. That is, they can be enabled/disabled independently. Differential Revision: https://reviews.llvm.org/D152405
2023-09-13[Driver][HLSL] Improve diagnostics for invalid shader model and stageJustin Bogner1-4/+18
This adds more validation that a dxil triple is actually useable when compiling HLSL. The OS field of the triple needs to be a versioned shader model. Later, we should set a default if this is empty and check that the version is a shader model we can actually handle. The Environment field of the triple needs to be specified and be a valid shader stage. I'd like to allow this to be empty and treat it like library, but allowing that currently crashes in DXIL metadata handling. Differential Revision: https://reviews.llvm.org/D159103
2023-09-11[SPIR-V] Add SPIR-V logical triple.Nathan Gauër1-1/+2
Clang implements SPIR-V with both Physical32 and Physical64 addressing models. This commit adds a new triple value for the Logical addressing model. Differential Revision: https://reviews.llvm.org/D155978
2023-09-07[clang] Introduce copy-on-write `CompilerInvocation` (#65412)Jan Svoboda1-14/+99
This PR introduces new copy-on-write `CompilerInvocation` class (`CowCompilerInvocation`), which will be used by the dependency scanner to reduce the number of copies performed when generating command lines for discovered modules.
2023-09-07[clang] Make the entire `CompilerInvocation` ref-counted (#65647)Jan Svoboda1-60/+70
This enables making the whole `CompilerInvocation` more efficient through copy-on-write.
2023-09-05[clang] NFCI: Change returned AnalyzerOptions smart pointer to referenceJan Svoboda1-2/+2
2023-09-05[clang] NFCI: Change returned LanguageOptions pointer to referenceJan Svoboda1-6/+6
2023-09-05[Clang] Enable AIX initial-exec TLS modeQiu Chaofan1-1/+1
Reviewed By: shchenz Differential Revision: https://reviews.llvm.org/D156076
2023-08-15[Driver] Refactor to use llvm Option's new Visibility flagsJustin Bogner1-6/+6
This is a big refactor of the clang driver's option handling to use the Visibility flags introduced in https://reviews.llvm.org/D157149. There are a few distinct parts, but they can't really be split into separate commits and still be made to compile. 1. We split out some of the flags in ClangFlags to ClangVisibility. Note that this does not include any subtractive flags. 2. We update the Flag definitions and OptIn/OptOut constructs in Options.td by hand. 3. We introduce and use a script, update_options_td_flags, to ease migration of flag definitions in Options.td, and we run that on Options.td. I intend to remove this later, but I'm committing it so that downstream forks can use the script to simplify merging. 4. We update calls to OptTable in the clang driver, cc1as, flang, and clangd to use the visibility APIs instead of Include/Exclude flags. 5. We deprecate the Include/Exclude APIs and add a release note. *if you are running into conflicts with this change:* Note that https://reviews.llvm.org/D157150 may also be the culprit and if so it should be handled first. The script in `clang/utils/update_options_td_flags.py` can help. Take the downstream side of all conflicts and then run the following: ``` % cd clang/include/clang/Driver % ../../../utils/update_options_td_flags.py Options.td > Options.td.new % mv Options.td.new Options.td ``` This will hopefully be sufficient, please take a look at the diff. Differential Revision: https://reviews.llvm.org/D157151
2023-08-15Reapply "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-6/+6
This reverts commit 4e3b89483a6922d3f48670bb1c50a37f342918c6, with fixes for places I'd missed updating in lld and lldb. I've also renamed OptionVisibility::Default to "DefaultVis" to avoid ambiguity since the undecorated name has to be available anywhere Options.inc is included. Original message follows: This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-14Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-6/+6
this is failing on bots, reverting to investigate. This reverts commit a16104e6da6f36f3d72dbf53d10ba56495a0d65a.
2023-08-14[Option] Add "Visibility" field and clone the OptTable APIs to use itJustin Bogner1-6/+6
This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-09[clang] NFC: Use compile-time option spelling when generating command lineJan Svoboda1-3/+2
When generating command lines, use the option spelling generated by TableGen (`StringLiteral`) instead of constructing it at runtime. This saves some needless allocations. Depends on D157029. Reviewed By: benlangmuir, MaskRay Differential Revision: https://reviews.llvm.org/D157054
2023-08-09[llvm] Construct option's prefixed name at compile-timeJan Svoboda1-6/+6
Some Clang command-line handling code could benefit from the option's prefixed name being a `StringLiteral`. This patch changes the `llvm::opt` TableGen backend to generate and emit that into the .inc file. Depends on D157028. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157029
2023-08-07Revert "Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`."Nico Weber1-4/+0
This reverts commit bddaa35177861545fc329123e55b6a3b34549507. Reverting as requested at https://reviews.llvm.org/D155895#4566945 (for breaking tests on Windows).
2023-08-07Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`.Dmitri Gribenko1-0/+4
Anonymous unions should be transparent wrt `[[clang::trivial_abi]]`. Consider the test input below: ``` struct [[clang::trivial_abi]] Trivial { Trivial() {} Trivial(Trivial&& other) {} Trivial& operator=(Trivial&& other) { return *this; } ~Trivial() {} }; static_assert(__is_trivially_relocatable(Trivial), ""); struct [[clang::trivial_abi]] S2 { S2(S2&& other) {} S2& operator=(S2&& other) { return *this; } ~S2() {} union { Trivial field; }; }; static_assert(__is_trivially_relocatable(S2), ""); ``` Before the fix Clang would warn that 'trivial_abi' is disallowed on 'S2' because it has a field of a non-trivial class type (the type of the anonymous union is non-trivial, because it doesn't have the `[[clang::trivial_abi]]` attribute applied to it). Consequently, before the fix the `static_assert` about `__is_trivially_relocatable` would fail. Note that `[[clang::trivial_abi]]` cannot be applied to the anonymous union, because Clang warns that 'trivial_abi' is disallowed on '(unnamed union at ...)' because its copy constructors and move constructors are all deleted. Also note that it is impossible to provide copy nor move constructors for anonymous unions and structs. Reviewed By: gribozavr2 Differential Revision: https://reviews.llvm.org/D155895
2023-08-03[clang] NFC: Avoid double allocation when generating command lineJan Svoboda1-11/+4
This patch makes use of the infrastructure established in D157046 to avoid needless allocations via `StringSaver`. Depends on D157046. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157048
2023-08-03[clang] Abstract away string allocation in command line generationJan Svoboda1-332/+306
This patch abstracts away the string allocation and vector push-back from command line generation. Instead, **all** generated arguments are passed into `ArgumentConsumer`, which may choose to do the string allocation and vector push-back, or something else entirely. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157046
2023-08-03[clang][cli] Accept option spelling as `Twine`Jan Svoboda1-11/+18
This will make it possible to accept the spelling as `StringLiteral` in D157029 and avoid some unnecessary allocations in a later patch. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157035
2023-07-11[clang] Support Unified LTO Bitcode FrontendMatthew Voss1-0/+2
The unified LTO pipeline creates a single LTO bitcode structure that can be used by Thin or Full LTO. This means that the LTO mode can be chosen at link time and that all LTO bitcode produced by the pipeline is compatible, from an optimization perspective. This makes the behavior of LTO a bit more predictable by normalizing the set of LTO features supported by each LTO bitcode file. Example usage: # Compile and link. Select regular LTO at link time. clang -flto -funified-lto -fuse-ld=lld foo.c # Compile and link. Select ThinLTO at link time. clang -flto=thin -funified-lto -fuse-ld=lld foo.c # Link separately, using ThinLTO. clang -c -flto -funified-lto foo.c # -flto={full,thin} are identical in terms of compilation actions clang -flto=thin -fuse-ld=lld foo.o # pass --lto=thin to ld.lld # Link separately, using regular LTO. clang -c -flto -funified-lto foo.c clang -flto -fuse-ld=lld foo.o # pass --lto=full to ld.lld The RFC discussing the details and rational for this change is here: https://discourse.llvm.org/t/rfc-a-unified-lto-bitcode-frontend/61774
2023-07-10[OpenMP][OMPIRBuilder] Rename IsEmbedded and IsTargetCodegen flagsSergio Afonso1-14/+16
This patch renames the `OpenMPIRBuilderConfig` flags to reduce confusion over their meaning. `IsTargetCodegen` becomes `IsGPU`, whereas `IsEmbedded` becomes `IsTargetDevice`. The `-fopenmp-is-device` compiler option is also renamed to `-fopenmp-is-target-device` and the `omp.is_device` MLIR attribute is renamed to `omp.is_target_device`. Getters and setters of all these renamed properties are also updated accordingly. Many unit tests have been updated to use the new names, but an alias for the `-fopenmp-is-device` option is created so that external programs do not stop working after the name change. `IsGPU` is set when the target triple is AMDGCN or NVIDIA PTX, and it is only valid if `IsTargetDevice` is specified as well. `IsTargetDevice` is set by the `-fopenmp-is-target-device` compiler frontend option, which is only added to the OpenMP device invocation for offloading-enabled programs. Differential Revision: https://reviews.llvm.org/D154591
2023-07-07[analyzer] Remove deprecated analyzer-config optionsBalazs Benics1-9/+0
The `consider-single-element-arrays-as-flexible-array-members` analyzer option was deprecated in clang-16, and now removed from clang-17 as promised in https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#static-analyzer This shouldn't change observable behavior. Differential Revision: https://reviews.llvm.org/D154481
2023-06-19[AIX][TLS] Relax front end diagnostics to accept the local-exec TLS modelAmy Kwan1-1/+1
This patch relaxes the front end AIX diagnostics added in D102070 to accept the local-exec TLS model, as we plan to support this model in a series of future patches. The diagnostics are relaxed when local-exec is used as a compiler option to `-ftls-model=*` and in the `__attribute__((tls_model("local-exec")))` attribute. Differential Revision: https://reviews.llvm.org/D149596
2023-06-15[OpenMP] Update the default version of OpenMP to 5.1Animesh Kumar1-4/+4
The default version of OpenMP is updated from 5.0 to 5.1 which means if -fopenmp is specified but -fopenmp-version is not specified with clang, the default version of OpenMP is taken to be 5.1. After modifying the Frontend for that, various LIT tests were updated. This patch contains all such changes. At a high level, these are the patterns of changes observed in LIT tests - # RUN lines which mentioned `-fopenmp-version=50` need to kept only if the IR for version 5.0 and 5.1 are different. Otherwise only one RUN line with no version info(i.e. default version) needs to be there. # Test cases of this sort already had the RUN lines with respect to the older default version 5.0 and the version 5.1. Only swapping the version specification flag `-fopenmp-version` from newer version RUN line to older version RUN line is required. # Diagnostics: Remove the 5.0 version specific RUN lines if there was no difference in the Diagnostics messages with respect to the default 5.1. # Diagnostics: In case there was any difference in diagnostics messages between 5.0 and 5.1, mention version specific messages in tests. # If the test contained version specific ifdef's e.g. "#ifdef OMP5" but there were no RUN lines for any other version than 5.X, then bring the code guarded by ifdef's outside and remove the ifdef's. # Some tests had RUN lines for both 5.0 and 5.1 versions, but it is found that the IR for 5.0 is not different from the 5.1, therefore such RUN lines are redundant. So, such duplicated lines are removed. # To generate CHECK lines automatically, use the script llvm/utils/update_cc_test_checks.py Reviewed By: saiislam, ABataev Differential Revision: https://reviews.llvm.org/D129635 (cherry picked from commit 9dd2999907dc791136a75238a6000f69bf67cf4e)
2023-06-07Add support for the NO_COLOR environment variableAaron Ballman1-1/+11
Clang currently supports disabling color diagnostic output via -fno-color-diagnostics. However, there is a somewhat long-standing push to support use of an environment variable to override color output so that users can set up their terminal such that most color output is disabled (largely for accessibility reasons). There are two competing de facto standards to accomplish this: NO_COLOR (https://no-color.org/) and CLICOLOR/CLICOLOR_FORCE (http://bixense.com/clicolors/). This patch adds support for NO_COLOR as that appears to be the more commonly supported feature, at least when comparing issues and pull requests: https://github.com/search?q=NO_COLOR&type=issues (2.2k issues, 35k pull requests) https://github.com/search?q=CLICOLOR&type=issues (1k issues, 3k pull requests) It's also the more straightforward and thoroughly-specified of the two options. If NO_COLOR is present as an environment variable (regardless of value), color output is suppressed unless the command line specifies use of color output (command line takes precedence over the environment variable). Differential Revision: https://reviews.llvm.org/D152285
2023-05-30print user provide value in tabstop diagnosticcsmoe1-1/+1
github issue: https://github.com/llvm/llvm-project/issues/62912 Reviewed By: jansvoboda11 Differential Revision: https://reviews.llvm.org/D151429
2023-05-17[gcov] Simplify cc1 options and remove CodeGenOptions EmitCovNotes/EmitCovArcsFangrui Song1-1/+1
After a07b135ce0c0111bd83450b5dc29ef0381cdbc39, we always pass -coverage-notes-file/-coverage-data-file for driver options -ftest-coverage/-fprofile-arcs/--coverage. As a bonus, we can make the following simplification to cc1 options: * `-ftest-coverage -coverage-notes-file a.gcno` => `-coverage-notes-file a.gcno` * `-fprofile-arcs -coverage-data-file a.gcda` => `-coverage-data-file a.gcda` and remove EmitCovNotes/EmitCovArcs.
2023-05-15[AIX][clang] Storage Locations for Constant PointersQiongsi Wu1-0/+22
This patch adds clang options `-mxcoff-roptr` and `-mno-xcoff-roptr` to specify storage locations for constant pointers on AIX. When the `-mxcoff-roptr` option is in effect, constant pointers, virtual function tables, and virtual type tables are placed in read-only storage. When the `-mno-xcoff-roptr` option is in effect, pointers, virtual function tables, and virtual type tables are placed are placed in read/write storage. This patch depends on https://reviews.llvm.org/D144189. Reviewed By: hubert.reinterpretcast, stephenpeckham Differential Revision: https://reviews.llvm.org/D144190
2023-04-27[clang] Apply -fcoverage-prefix-map reverse orderGulfem Savrun Yeniceri1-2/+1
This patch changes handling multiple -fcoverage-prefix-map options to match GCC's behavior. GCC applies prefix remappings that are provided in reverse order (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109591). Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D148757
2023-04-25-fdebug-prefix-map=: make the last win when multiple prefixes matchFangrui Song1-2/+1
For `clang -c -g -fdebug-prefix-map=a/b=y -fdebug-prefix-map=a=x a/b/c.c`, we apply the longest prefix substitution, but GCC has always been picking the last applicable option (`a=x`, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109591). I feel that GCC's behavior is reasonable given the convention that the last value wins for the same option. Before D49466, Clang appeared to apply the shortest prefix substitution, which likely made the least sense. Reviewed By: #debug-info, scott.linder Differential Revision: https://reviews.llvm.org/D148975
2023-04-24[Driver] Simplify handling of -mabi=vec-default -mabi=vec-extabiFangrui Song1-10/+0
And fix a minor issue that -mabi=vec-extabi -mabi=vec-default should not pass "-bplugin_opt:-vec-extabi" to ld.
2023-04-24[Clang] Accept and forward `-fconvergent-functions` in the driverJoseph Huber1-3/+3
Currently the `-fconvergent-functions` option is primarily used by GPU toolchains to enforce convergent operations in line with the semantics. This option previously was only supported via `-Xclang` and would show up as unused if passed to the driver. This patch allows the driver to forward it. This is mostly useful for users wishing to target GPU toolchains directly via `--target=` without an offloading runtime. Reviewed By: JonChesterfield, MaskRay Differential Revision: https://reviews.llvm.org/D149019
2023-04-23Remove ExplicitEmulatedTLS and simplify -femulated-tls handlingFangrui Song1-7/+2
Currently clangDriver passes -femulated-tls and -fno-emulated-tls to cc1. cc1 forwards the option to LLVMCodeGen and ExplicitEmulatedTLS is used to decide the value. Simplify this by moving the Clang decision to clangDriver and moving the LLVM decision to InitTargetOptionsFromCodeGenFlags.
2023-03-29[NFC][Clang] Move DebugOptions to llvm/Frontend for reuse in FlangKiran Chandramohan1-27/+29
This patch moves the Debug Options to llvm/Frontend so that it can be shared by Flang as well. Reviewed By: kiranchandramohan, awarzynski Differential Revision: https://reviews.llvm.org/D142347
2023-02-13[Driver] Add --vfsoverlay flagAlex Brachet1-1/+1
This flag implies `-ivfsoverlay`, and additionally passes the same argument to the linker if it supports it. At present the only linker which does is lld-link, so this functionality has only been added to the MSVC toolchain. Additionally this option has been made a CoreOption so that clang-cl can use it without `-Xclang` Differential Revision: https://reviews.llvm.org/D141808
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott1-1/+1
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2023-02-08[clang][cli] Simplify repetitive macro invocationsJan Svoboda1-197/+56
Since we now only support Visual Studio 2019 16.7 and newer, we're able to use the `/Zc:preprocessor` flag that turns on the standards-conforming preprocessor. It (among other things) correctly expands `__VA_ARGS__` (see https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170#macro-arguments-are-unpacked). This enables us to get rid of some repetitive boilerplate in Clang's command-line parser/generator. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D135128
2023-02-08[clang][deps] Ensure module invocation can be serializedBen Langmuir1-27/+66
When reseting modular options, propagate the values from certain options that have ImpliedBy relations instead of setting to the default. Also, verify in clang-scan-deps that the command line produced round trips exactly. Ideally we would automatically derive the set of options that need this kind of propagation, but for now there aren't very many impacted. rdar://105148590 Differential Revision: https://reviews.llvm.org/D143446
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-02-01[Clang] avoid relying on StringMap iteration order when roundtripping ↵Erik Desjardins1-4/+10
-analyzer-config I am working on another patch that changes StringMap's hash function, which changes the iteration order here, and breaks some tests, specifically: clang/test/Analysis/NSString.m clang/test/Analysis/shallow-mode.m with errors like: generated arguments do not match in round-trip generated arguments #1 in round-trip: <...> "-analyzer-config" "ipa=inlining" "-analyzer-config" "max-nodes=75000" <...> generated arguments #2 in round-trip: <...> "-analyzer-config" "max-nodes=75000" "-analyzer-config" "ipa=inlining" <...> To avoid this, sort the options by key, instead of using the default map iteration order. Reviewed By: jansvoboda11, MaskRay Differential Revision: https://reviews.llvm.org/D142861
2023-02-01[NFC][Profile] Access profile through VirtualFileSystemSteven Wu1-6/+15
Make the access to profile data going through virtual file system so the inputs can be remapped. In the context of the caching, it can make sure we capture the inputs and provided an immutable input as profile data. Reviewed By: akyrtzi, benlangmuir Differential Revision: https://reviews.llvm.org/D139052
2023-01-19Revert "[Clang] Give Clang the ability to use a shared stat cache"Fred Riss1-27/+1
This reverts commit c5abe893120b115907376359a5809229a9f9608a. This reverts commit a033dbbe5c43247b60869b008e67ed86ed230eaa. This broke the build with -DLLVM_LINK_LLVM_DYLIB=ON. Reverting while I investigate.
2023-01-18[Clang] Give Clang the ability to use a shared stat cacheFred Riss1-1/+27
Every Clang instance uses an internal FileSystemStatCache to avoid stating the same content multiple times. However, different instances of Clang will contend for filesystem access for their initial stats during HeaderSearch or module validation. On some workloads, the time spent in the kernel in these concurrent stat calls has been measured to be over 20% of the overall compilation time. This is extremly wassteful when most of the stat calls target mostly immutable content like a SDK. This commit introduces a new tool `clang-stat-cache` able to generate an OnDiskHashmap containing the stat data for a given filesystem hierarchy. The driver part of this has been modeled after -ivfsoverlay given the similarities with what it influences. It introduces a new -ivfsstatcache driver option to instruct Clang to use a stat cache generated by `clang-stat-cache`. These stat caches are inserted at the bottom of the VFS stack (right above the real filesystem). Differential Revision: https://reviews.llvm.org/D136651
2023-01-14[clang] Remove remaining uses of llvm::Optional (NFC)Kazu Hirata1-1/+0
This patch removes several "using" declarations and #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-4/+5
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716