[clang] [clang] Reduce the small vector size for DeclTypeInfo. (PR #148788)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 14 23:53:28 PDT 2025
https://github.com/hokein created https://github.com/llvm/llvm-project/pull/148788
The `Declarator` class is large (4584 bytes) and used as a stack-local variable during parsing.
This patch reduces the default size of its `DeclTypeInfo` member, reducing the overall size down to 3880 bytes. This allows clang handle more deeply nested expressions without exhausting the stack.
Combined with #148726, the nesting threshold for such expressions increases to `~1100`.
No performance impact being [observed](https://llvm-compile-time-tracker.com/compare.php?from=d4f5ed6a23464cbe831820cb695aa1d39b11e4aa&to=66ba54b8a295cc2759387ef2a4a162de2ad4946e&stat=instructions:u).
>From 66ba54b8a295cc2759387ef2a4a162de2ad4946e Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Mon, 14 Jul 2025 21:19:15 +0200
Subject: [PATCH] Use a smaller vector for DeclTypeInfo.
---
clang/include/clang/Sema/DeclSpec.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 567ad2d5934d4..4b7c8d609735f 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -1918,7 +1918,7 @@ class Declarator {
/// parsed. This is pushed from the identifier out, which means that element
/// #0 will be the most closely bound to the identifier, and
/// DeclTypeInfo.back() will be the least closely bound.
- SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
+ SmallVector<DeclaratorChunk, 4> DeclTypeInfo;
/// InvalidType - Set by Sema::GetTypeForDeclarator().
LLVM_PREFERRED_TYPE(bool)
More information about the cfe-commits
mailing list