[clang] [CMake][CodeGen] Add PCH for Clang CodeGen (PR #206018)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 02:49:10 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
The change to CGCall is required to avoid collisions of operator|=.
---
Full diff: https://github.com/llvm/llvm-project/pull/206018.diff
3 Files Affected:
- (modified) clang/lib/CodeGen/CGCall.h (+2-20)
- (modified) clang/lib/CodeGen/CMakeLists.txt (+4)
- (added) clang/lib/CodeGen/pch.h (+22)
``````````diff
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"
``````````
</details>
https://github.com/llvm/llvm-project/pull/206018
More information about the cfe-commits
mailing list