Skip to content

[clang][deps] Store common, partially-formed invocation #65677

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
merged 1 commit into from
Sep 7, 2023

Conversation

jansvoboda11
Copy link
Contributor

We create one CompilerInvocation for each modular dependency we discover. This means we create a lot of copies, even though most of the invocation is the same between modules. This patch makes use of the copy-on-write flavor of CompilerInvocation to share the common parts, reducing memory usage and speeding up the scan.

@jansvoboda11 jansvoboda11 requested a review from a team as a code owner September 7, 2023 21:20
CI.getHeaderSearchOpts().ModulesIgnoreMacros.clear();
}

return CI;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going through CowCompilerInvocation(const CompilerInvocation &X), right? Could we add an && version that steals the sub objects without copying them? Obviously less important than avoiding the per-module copies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm happy to do that in a follow-up (constantly rebasing is kinda annoying).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in #66301.

@@ -117,14 +112,37 @@ ModuleDepCollector::makeInvocationForModuleBuildWithoutOutputs(
CI.getFrontendOpts().ARCMTAction = FrontendOptions::ARCMT_None;
CI.getFrontendOpts().ObjCMTAction = FrontendOptions::ObjCMT_None;
CI.getFrontendOpts().MTMigrateDir.clear();
CI.getLangOpts().ModuleName = Deps.ID.ModuleName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could clear this string to make sure it won't get copied.

@jansvoboda11 jansvoboda11 merged commit 9208065 into llvm:main Sep 7, 2023
@jansvoboda11 jansvoboda11 deleted the common-ci branch September 7, 2023 22:49
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Sep 12, 2023
We create one `CompilerInvocation` for each modular dependency we
discover. This means we create a lot of copies, even though most of the
invocation is the same between modules. This patch makes use of the
copy-on-write flavor of `CompilerInvocation` to share the common parts,
reducing memory usage and speeding up the scan.
jansvoboda11 added a commit to swiftlang/llvm-project that referenced this pull request Oct 5, 2023
We create one `CompilerInvocation` for each modular dependency we
discover. This means we create a lot of copies, even though most of the
invocation is the same between modules. This patch makes use of the
copy-on-write flavor of `CompilerInvocation` to share the common parts,
reducing memory usage and speeding up the scan.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants