[clang] 0173f46 - [CIR][CMake] Add PCH for clangCIR. NFC (#231068)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 15 00:50:55 PDT 2026


Author: Fangrui Song
Date: 2026-10-15T00:50:49-07:00
New Revision: 0173f46b7d9ddf1aba1394f5f6d04571a29c5d57

URL: https://github.com/llvm/llvm-project/commit/0173f46b7d9ddf1aba1394f5f6d04571a29c5d57
DIFF: https://github.com/llvm/llvm-project/commit/0173f46b7d9ddf1aba1394f5f6d04571a29c5d57.diff

LOG: [CIR][CMake] Add PCH for clangCIR. NFC (#231068)

clangCIR reuses clangAST's precompiled header, so each of its 54 files
reparses the MLIR and CIR dialect headers. Add a private PCH like
clangCodeGen's (#206018).

Rebuilding clangCIR (Release+Asserts, 28 threads):

```
              summed per-file   user CPU   wall
before        312 s             282 s      20.0 s
after         79 s + 6 s PCH    78 s       18.1 s
```

LLM-aided

Added: 
    clang/lib/CIR/CodeGen/pch.h

Modified: 
    clang/lib/CIR/CodeGen/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/CodeGen/CMakeLists.txt b/clang/lib/CIR/CodeGen/CMakeLists.txt
index 1b5c0b91b394e..6d84faf70d11d 100644
--- a/clang/lib/CIR/CodeGen/CMakeLists.txt
+++ b/clang/lib/CIR/CodeGen/CMakeLists.txt
@@ -61,6 +61,10 @@ add_clang_library(clangCIR
   Targets/NVPTX.cpp
   Targets/SPIRV.cpp
 
+  DISABLE_PCH_REUSE # PCH contains private headers
+  PRECOMPILE_HEADERS
+  [["pch.h"]]
+
   DEPENDS
   MLIRCIR
   MLIRCIROpInterfacesIncGen

diff  --git a/clang/lib/CIR/CodeGen/pch.h b/clang/lib/CIR/CodeGen/pch.h
new file mode 100644
index 0000000000000..ab52fad5468ff
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/pch.h
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 clangCIR. Uses private headers.
+///
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenBuilder.h"
+#include "CIRGenCXXABI.h"
+#include "CIRGenFunction.h"
+#include "CIRGenModule.h"
+#include "CIRGenValue.h"
+#include "clang/AST/pch.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/MissingFeatures.h"
+#include "mlir/IR/pch.h"
+#include "llvm/IR/pch.h"
+#include "llvm/Support/pch.h"


        


More information about the cfe-commits mailing list