forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 344
[llvm][clang] Cherry-pick performance improvements to command line generation #7233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jansvoboda11
merged 12 commits into
stable/20221013
from
jan_svoboda/stable-20221013-cmdline-cherry-pick
Aug 17, 2023
Merged
[llvm][clang] Cherry-pick performance improvements to command line generation #7233
jansvoboda11
merged 12 commits into
stable/20221013
from
jan_svoboda/stable-20221013-cmdline-cherry-pick
Aug 17, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Locally, these tests fail for
|
Coooooool. |
@swift-ci please test |
artemcm
approved these changes
Aug 15, 2023
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. Among other things, it correctly expands __VA_ARGS__. This enables removal of some boilerplate in D135128. Reviewed By: Bigcheese, thieta Differential Revision: https://reviews.llvm.org/D135128
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
The `const char *` storage backing StringLiteral has static lifetime. Making `Twine` aware of that allows us to avoid allocating heap memory in some contexts (e.g. avoid passing it to `StringSaver::save()` in a follow-up Clang patch). Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157010
The `Twine::str()` function currently always allocates heap memory via `std::string`. However, some instances of `Twine` don't need an intermediate buffer at all, and the rest can attempt to print into a stack buffer first. This is intentionally not making use of `Twine::isSingleStringLiteral()` from D157010 to skip saving the string in the bump-pointer allocator, since the `StringSaver` documentation suggests that MUST happen for every given string. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157015
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
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
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
This patch makes use of the infrastructure established in D157046 to speed up computation of the canonical context hash in the dependency scanner. This is somewhat hot code, since it's ran for all modules in the dependency graph of every TU. I also tried an alternative approach that tried to avoid allocations as much as possible (essentially doing `HashBuilder.add(Arg.toStringRef(ArgVec))`), but that turned out to be slower than approach in this patch. Note that this is not problematic in the same way command-line hashing used to be prior D143027. The lambda is now being called even for constant strings. Depends on D157046. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D157052
All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157028
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
… line 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
d50dc79
to
2fc3863
Compare
swiftlang/swift#67950 |
1 similar comment
swiftlang/swift#67950 |
…ng preprocessor rdar://113996252
f0c5816
to
72de458
Compare
swiftlang/swift#67950 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.