[clang] [CMake][CodeGen] Add PCH for Clang CodeGen (PR #206018)
Alexis Engelke via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 02:48:36 PDT 2026
https://github.com/aengelke created https://github.com/llvm/llvm-project/pull/206018
The change to CGCall is required to avoid collisions of operator|=.
>From b88ff163f8a78182330eaee3e1291ad7a38f8f99 Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Fri, 26 Jun 2026 09:47:56 +0000
Subject: [PATCH] [spr] initial version
Created using spr 1.3.8-wip
---
clang/lib/CodeGen/CGCall.h | 22 ++--------------------
clang/lib/CodeGen/CMakeLists.txt | 4 ++++
clang/lib/CodeGen/pch.h | 22 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 20 deletions(-)
create mode 100644 clang/lib/CodeGen/pch.h
diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index 675c448ab0b00..5df7f0d08d070 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -21,6 +21,7 @@
#include "clang/AST/CanonicalType.h"
#include "clang/AST/GlobalDecl.h"
#include "clang/AST/Type.h"
+#include "clang/Basic/BitmaskEnum.h"
#include "clang/CodeGen/ModuleLinker.h"
#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/IR/Value.h"
@@ -411,28 +412,9 @@ enum class FnInfoOpts {
IsInstanceMethod = 1 << 0,
IsChainCall = 1 << 1,
IsDelegateCall = 1 << 2,
+ LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/IsDelegateCall)
};
-inline FnInfoOpts operator|(FnInfoOpts A, FnInfoOpts B) {
- return static_cast<FnInfoOpts>(llvm::to_underlying(A) |
- llvm::to_underlying(B));
-}
-
-inline FnInfoOpts operator&(FnInfoOpts A, FnInfoOpts B) {
- return static_cast<FnInfoOpts>(llvm::to_underlying(A) &
- llvm::to_underlying(B));
-}
-
-inline FnInfoOpts &operator|=(FnInfoOpts &A, FnInfoOpts B) {
- A = A | B;
- return A;
-}
-
-inline FnInfoOpts &operator&=(FnInfoOpts &A, FnInfoOpts B) {
- A = A & B;
- return A;
-}
-
struct DisableDebugLocationUpdates {
CodeGenFunction &CGF;
DisableDebugLocationUpdates(CodeGenFunction &CGF);
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index d003ec209f051..853f038c4186b 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -163,6 +163,10 @@ add_clang_library(clangCodeGen
TrapReasonBuilder.cpp
VarBypassDetector.cpp
+ DISABLE_PCH_REUSE # PCH contains private headers
+ PRECOMPILE_HEADERS
+ [["pch.h"]]
+
DEPENDS
vt_gen
intrinsics_gen
diff --git a/clang/lib/CodeGen/pch.h b/clang/lib/CodeGen/pch.h
new file mode 100644
index 0000000000000..137fe034dd83b
--- /dev/null
+++ b/clang/lib/CodeGen/pch.h
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// Precompiled header for clangCodeGen. Uses private headers.
+///
+//===----------------------------------------------------------------------===//
+
+#include "ABIInfoImpl.h"
+#include "Address.h"
+#include "CGBuilder.h"
+#include "CGCXXABI.h"
+#include "CGValue.h"
+#include "CodeGenFunction.h"
+#include "CodeGenModule.h"
+#include "clang/AST/pch.h"
+#include "llvm/IR/pch.h"
+#include "llvm/Support/pch.h"
More information about the cfe-commits
mailing list