[flang-commits] [flang] [flang] Use precompiled headers in Lower, Parser and Semantics (PR #131137)

via flang-commits flang-commits at lists.llvm.org
Thu Mar 13 06:11:56 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-parser

Author: Kajetan Puchalski (mrkajetanp)

<details>
<summary>Changes</summary>

Precompiling larger headers can save a lot of compile time across various compilation units.

Selected compile time & memory improvements are as follows:

flang/lib/Parser/Fortran-parsers.cpp:
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:47.31 -> 0:41.68 Maximum resident set size (kbytes): 2062140 -> 1745584

flang/lib/Lower/Bridge.cpp:
Elapsed (wall clock) time (h:mm:ss or m:ss): 1:19.16 -> 0:45.86 Maximum resident set size (kbytes): 3849144 -> 2443476

flang/lib/Lower/PFTBuilder.cpp
Elapsed (wall clock) time (h:mm:ss or m:ss): 1:29.24 -> 1:00.99 Maximum resident set size (kbytes): 4218368 -> 2923128

flang/lib/Lower/Allocatable.cpp
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:53.03 -> 0:22.50 Maximum resident set size (kbytes): 3092840 -> 2116908

flang/lib/Semantics/Semantics.cpp
Elapsed (wall clock) time (h:mm:ss or m:ss): 1:18.75 -> 1:00.20 Maximum resident set size (kbytes): 3527744 -> 2545308

While the newly added precompiled headers are as follows:

Parser:
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:09.62 Maximum resident set size (kbytes): 1034608

Lower:
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:41.33 Maximum resident set size (kbytes): 3615240

Semantics:
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:26.69 Maximum resident set size (kbytes): 2403776

---
Full diff: https://github.com/llvm/llvm-project/pull/131137.diff


3 Files Affected:

- (modified) flang/lib/Lower/CMakeLists.txt (+11) 
- (modified) flang/lib/Parser/CMakeLists.txt (+8) 
- (modified) flang/lib/Semantics/CMakeLists.txt (+9) 


``````````diff
diff --git a/flang/lib/Lower/CMakeLists.txt b/flang/lib/Lower/CMakeLists.txt
index 0bd9a47cd040f..bc817ff8f1f3e 100644
--- a/flang/lib/Lower/CMakeLists.txt
+++ b/flang/lib/Lower/CMakeLists.txt
@@ -73,3 +73,14 @@ add_flang_library(FortranLower
   MLIRLLVMDialect
   MLIRSCFToControlFlow
 )
+
+target_precompile_headers(FortranLower PRIVATE
+  [["flang/Lower/ConvertExpr.h"]]
+  [["flang/Lower/SymbolMap.h"]]
+  [["flang/Lower/AbstractConverter.h"]]
+  [["flang/Lower/IterationSpace.h"]]
+  [["flang/Lower/CallInterface.h"]]
+  [["flang/Lower/BoxAnalyzer.h"]]
+  [["flang/Lower/PFTBuilder.h"]]
+  [["flang/Lower/DirectivesCommon.h"]]
+)
diff --git a/flang/lib/Parser/CMakeLists.txt b/flang/lib/Parser/CMakeLists.txt
index 76fe3d7ce6ba4..1855b8a841ba7 100644
--- a/flang/lib/Parser/CMakeLists.txt
+++ b/flang/lib/Parser/CMakeLists.txt
@@ -36,3 +36,11 @@ add_flang_library(FortranParser
   omp_gen
   acc_gen
 )
+
+target_precompile_headers(FortranParser PRIVATE
+  [["flang/Parser/parsing.h"]]
+  [["flang/Parser/parse-tree.h"]]
+  [["flang/Parser/provenance.h"]]
+  [["flang/Parser/message.h"]]
+  [["flang/Parser/parse-tree-visitor.h"]]
+)
diff --git a/flang/lib/Semantics/CMakeLists.txt b/flang/lib/Semantics/CMakeLists.txt
index 93bf0c7c5facd..bd8cc47365f06 100644
--- a/flang/lib/Semantics/CMakeLists.txt
+++ b/flang/lib/Semantics/CMakeLists.txt
@@ -64,3 +64,12 @@ add_flang_library(FortranSemantics
   FrontendOpenACC
   TargetParser
 )
+
+target_precompile_headers(FortranSemantics PRIVATE
+  [["flang/Semantics/semantics.h"]]
+  [["flang/Semantics/type.h"]]
+  [["flang/Semantics/openmp-modifiers.h"]]
+  [["flang/Semantics/expression.h"]]
+  [["flang/Semantics/tools.h"]]
+  [["flang/Semantics/symbol.h"]]
+)

``````````

</details>


https://github.com/llvm/llvm-project/pull/131137


More information about the flang-commits mailing list