Skip to content

Add PCH for Sema Structure#1

Open
jenetscaria-mcw wants to merge 3 commits into
mainfrom
llvm-buildtime-changes
Open

Add PCH for Sema Structure#1
jenetscaria-mcw wants to merge 3 commits into
mainfrom
llvm-buildtime-changes

Conversation

@jenetscaria-mcw

Copy link
Copy Markdown
Owner

Added support for PCH for clang Sema

Extends the PCH infrastructure (already there for LLVMSupport,
LLVMCore, LLVMCodeGen, clangAST) to clangSema, which was the largest
remaining gap.

clangSema (clang/include/clang/Sema/pch.h):
- Builds on clang/AST/pch.h (inheriting ASTContext, Expr, Decl, etc.)
- Adds the 8 most commonly included Sema-specific headers across the
  86 .cpp files in clang/lib/Sema/:
  Sema.h (698KB/15690 lines, 36 TUs), Lookup.h (30 TUs),
  Initialization.h (31 TUs), ScopeInfo.h (26 TUs), Scope.h (20 TUs),
  DiagnosticSema.h (26 TUs), TargetInfo.h (34 TUs),
  Preprocessor.h (25 TUs)
LLVM_OPTIMIZED_TABLEGEN defaults to OFF but the docs recommend enabling it for Release builds to avoid a slow debug-mode
llvm-tblgen bottlenecking the rest of the build. The X86 target alone generates 18 .inc files (X86GenDAGISel.inc,
X86GenAsmMatcher.inc, etc.) which are all on the critical path — no X86 source file can start compiling until they finish.

Auto-enable LLVM_OPTIMIZED_TABLEGEN when: - Not cross-compiling (host tools are already used when cross-compiling) -
CMAKE_BUILD_TYPE is Release or RelWithDebInfo - The user has not explicitly set LLVM_OPTIMIZED_TABLEGEN

Users who want the old behaviour can pass -DLLVM_OPTIMIZED_TABLEGEN=OFF
Split SemaExpr.cpp (877 KB, ~22K lines) at the natural section boundary
of the "Clang Extensions" block (blocks, __unknown_anytype, typeof,
__builtin_choose_expr, etc.) into a separate translation unit
SemaExprExtensions.cpp (~5,200 lines).

The RebuildUnknownAnyFunction struct and its wrapper function were
relocated from the extensions section to the main file before their
first call site, to preserve internal linkage semantics.

This allows clangSema to compile SemaExpr.cpp and SemaExprExtensions.cpp
in parallel, reducing the build bottleneck from this single large TU.
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