Add PCH for Sema Structure#1
Open
jenetscaria-mcw wants to merge 3 commits into
Open
Conversation
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.
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.
Added support for PCH for clang Sema