[flang-commits] [flang] [flang] Use precompiled parsing headers (PR #130600)
Kajetan Puchalski via flang-commits
flang-commits at lists.llvm.org
Mon Mar 10 06:12:11 PDT 2025
https://github.com/mrkajetanp created https://github.com/llvm/llvm-project/pull/130600
Most of the high memory usage and compilation time in the frontend units is due to including large parsing headers.
This commit moves out several of the largest parsing headers into a new precompiled header linked to flangFrontend.
The new compilation metrics for FrontendActions.cpp are as follows:
User time (seconds): 38.40
System time (seconds): 2.00
Maximum resident set size (kbytes): 2710964 (2.58 GB) (vs 3.78 GB)
ParserActions.cpp:
User time (seconds): 69.37
System time (seconds): 1.81
Maximum resident set size (kbytes): 2599456 (2.47 GB) (vs 4 GB)
Alongside the new precompiled header compilation unit
User time (seconds): 41.61
System time (seconds): 2.72
Maximum resident set size (kbytes): 3107644 (2.96 GB)
>From ff2f02e01e292df3bbfc787e1b9716f3ca2285ee Mon Sep 17 00:00:00 2001
From: Kajetan Puchalski <kajetan.puchalski at arm.com>
Date: Fri, 7 Mar 2025 15:35:57 +0000
Subject: [PATCH] [flang] Use precompiled parsing headers
Most of the high memory usage and compilation time in the frontend units
is due to including large parsing headers.
This commit moves out several of the largest parsing headers into a new
precompiled header linked to flangFrontend.
The new compilation metrics for FrontendActions.cpp are as follows:
User time (seconds): 38.40
System time (seconds): 2.00
Maximum resident set size (kbytes): 2710964 (2.58 GB) (vs 3.78 GB)
ParserActions.cpp:
User time (seconds): 69.37
System time (seconds): 1.81
Maximum resident set size (kbytes): 2599456 (2.47 GB) (vs 4 GB)
Alongside the new precompiled header compilation unit
User time (seconds): 41.61
System time (seconds): 2.72
Maximum resident set size (kbytes): 3107644 (2.96 GB)
Signed-off-by: Kajetan Puchalski <kajetan.puchalski at arm.com>
---
flang/lib/Frontend/CMakeLists.txt | 8 ++++++++
flang/lib/Frontend/CompilerInstance.cpp | 1 -
flang/lib/Frontend/FrontendActions.cpp | 1 -
flang/lib/Frontend/ParserActions.cpp | 4 ----
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index c80373799b015..e8a098613e26f 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -72,3 +72,11 @@ add_flang_library(flangFrontend
clangBasic
clangDriver
)
+
+target_precompile_headers(flangFrontend PRIVATE
+ [["flang/Parser/parsing.h"]]
+ [["flang/Parser/parse-tree.h"]]
+ [["flang/Parser/dump-parse-tree.h"]]
+ [["flang/Lower/PFTBuilder.h"]]
+ [["flang/Lower/Bridge.h"]]
+)
diff --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index b1fa32ecb4cfc..5fd3b76b6741b 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -13,7 +13,6 @@
#include "flang/Frontend/CompilerInstance.h"
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/TextDiagnosticPrinter.h"
-#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Semantics/semantics.h"
#include "flang/Support/Fortran-features.h"
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 94de376aaf7d6..cd3e206c19550 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -15,7 +15,6 @@
#include "flang/Frontend/CompilerInvocation.h"
#include "flang/Frontend/FrontendOptions.h"
#include "flang/Frontend/ParserActions.h"
-#include "flang/Lower/Bridge.h"
#include "flang/Lower/Support/Verifier.h"
#include "flang/Optimizer/Dialect/Support/FIRContext.h"
#include "flang/Optimizer/Dialect/Support/KindMapping.h"
diff --git a/flang/lib/Frontend/ParserActions.cpp b/flang/lib/Frontend/ParserActions.cpp
index cc7e72f696f96..7967832c80ac9 100644
--- a/flang/lib/Frontend/ParserActions.cpp
+++ b/flang/lib/Frontend/ParserActions.cpp
@@ -12,10 +12,6 @@
#include "flang/Frontend/ParserActions.h"
#include "flang/Frontend/CompilerInstance.h"
-#include "flang/Lower/Bridge.h"
-#include "flang/Lower/PFTBuilder.h"
-#include "flang/Parser/dump-parse-tree.h"
-#include "flang/Parser/parsing.h"
#include "flang/Parser/provenance.h"
#include "flang/Parser/source.h"
#include "flang/Parser/unparse.h"
More information about the flang-commits
mailing list