Skip to content

[clang] Reduce LateInstantiatedAttrVec vector default size. #142840

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
Jun 5, 2025

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Jun 4, 2025

This increases clang's template instantiation depths.

I can see 7% increase (1510 -> 1612 on my local machine) for the clang/test/SemaTemplate/instantiation-depth-default.cpp case.

No performance regressions have been observed: https://llvm-compile-time-tracker.com/compare.php?from=5f8cf33650c0c71119ecf81f07014329d9466d0d&to=05c2403b0f784325f5b88760ef43a15b6aaf4181&stat=instructions:u

@hokein hokein requested review from cor3ntin and AaronBallman June 4, 2025 20:02
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 4, 2025

@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)

Changes

This increases clang's template instantiation depths.

I can see 7% increase (1510 -> 1612 on my local machine) for the clang/test/SemaTemplate/instantiation-depth-default.cpp case.

No performance regressions have been observed: https://llvm-compile-time-tracker.com/compare.php?from=5f8cf33650c0c71119ecf81f07014329d9466d0d&to=05c2403b0f784325f5b88760ef43a15b6aaf4181&stat=instructions:u


Full diff: https://github.com/llvm/llvm-project/pull/142840.diff

1 Files Affected:

  • (modified) clang/include/clang/Sema/Sema.h (+1-1)
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 84d30561fecde..25246374a3c36 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -14015,7 +14015,7 @@ class Sema final : public SemaBase {
                               Decl *D)
         : TmplAttr(A), Scope(S), NewDecl(D) {}
   };
-  typedef SmallVector<LateInstantiatedAttribute, 16> LateInstantiatedAttrVec;
+  typedef SmallVector<LateInstantiatedAttribute, 1> LateInstantiatedAttrVec;
 
   void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
                         const Decl *Pattern, Decl *Inst,

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

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

LGTM, wow, that's a really nice win for such an easy change. Thank you!

@hokein hokein merged commit 702e228 into llvm:main Jun 5, 2025
14 checks passed
@hokein hokein deleted the perf/small-late-attr-vec branch June 5, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants