Repository navigation
Skip parsing non-templated dependency function bodies in rs_bindings_from_cc. - #3280
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…from_cc. Header analysis spends much of its time parsing and instantiating inline function bodies from dependency headers that it never uses. This matters most for targets that parse their dependencies from source instead of loading header modules: profiles showed 43% to 59% of CPU time in `Parser::ParseFunctionStatementBody` and `Sema::PerformPendingInstantiations` on such bodies. Enable `FrontendOptions::SkipFunctionBodies` and override `AstConsumer::shouldSkipFunctionBody` to skip only non-templated, non-dependent function definitions that the importer doesn't treat as part of the current target. Bodies stay parsed for current-target functions (needed by `GetMemberFuncSemantic`, `--carcinize`, and diagnostics), for members of full class template specializations (which the importer attributes to the current target wherever they are written), and for templated and dependent functions (needed for template validation and `std::make_unique` `lifetimebound` inference). Clang's `Sema::canSkipFunctionBody` already keeps `constexpr`, `consteval`, and deduced-return bodies. To keep the filter and the importer in agreement, move the importer's ownership rules into the free functions `GetOwningTarget` and `GetOwningTargetOfLocation`, which both use. Add the kill switch `--//third_party/crubit/rs_bindings_from_cc/bazel_support:skip_dependency_function_bodies=false` (tool flag `--skip_dependency_function_bodies`, default true). The aspect only passes the tool flag when it is false, because older `rs_bindings_from_cc` binaries reject unknown flags. PiperOrigin-RevId: 1035182488
This branch has not been deployed
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
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.
Skip parsing non-templated dependency function bodies in rs_bindings_from_cc.
Header analysis spends much of its time parsing and instantiating inline function bodies from dependency headers that it never uses. This matters most for targets that parse their dependencies from source instead of loading header modules: profiles showed 43% to 59% of CPU time in
Parser::ParseFunctionStatementBodyandSema::PerformPendingInstantiationson such bodies.Enable
FrontendOptions::SkipFunctionBodiesand overrideAstConsumer::shouldSkipFunctionBodyto skip only non-templated, non-dependent function definitions that the importer doesn't treat as part of the current target. Bodies stay parsed for current-target functions (needed byGetMemberFuncSemantic,--carcinize, and diagnostics), for members of full class template specializations (which the importer attributes to the current target wherever they are written), and for templated and dependent functions (needed for template validation andstd::make_uniquelifetimeboundinference). Clang'sSema::canSkipFunctionBodyalready keepsconstexpr,consteval, and deduced-return bodies.To keep the filter and the importer in agreement, move the importer's ownership rules into the free functions
GetOwningTargetandGetOwningTargetOfLocation, which both use.Add the kill switch
--//third_party/crubit/rs_bindings_from_cc/bazel_support:skip_dependency_function_bodies=false(tool flag--skip_dependency_function_bodies, default true). The aspect only passes the tool flag when it is false, because olderrs_bindings_from_ccbinaries reject unknown flags.