[CSPGO] Update the gate of cspgo

Update gate to allow CSPGO to be enabled after PGO
This commit is contained in:
liyancheng 2024-12-30 22:21:22 +08:00
parent 5a6f8255b0
commit 3d3705d12d
2 changed files with 97 additions and 1 deletions

View File

@ -0,0 +1,88 @@
From 25f3b77d288e26b198c7836c3ed9b4fb0a85a48a Mon Sep 17 00:00:00 2001
From: liyancheng <412998149@qq.com>
Date: Mon, 16 Dec 2024 15:52:22 +0800
Subject: [PATCH] [CSPGO] Update the gate of cspgo
Update gate to allow CSPGO to be enabled after PGO
---
gcc/tree-profile.cc | 59 +++++++++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 23 deletions(-)
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index ace1fe31c..3c57a0a75 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -1108,34 +1108,47 @@ public:
/* opt_pass methods: */
virtual bool gate (function *)
{
- return (flag_csprofile_generate || flag_csprofile_use);
- }
- /* The main process of cspgo is in csprofile_transform, execute does not need
- to do anything. */
- virtual unsigned int execute (function *)
- {
- if (!profile_data_prefix)
- error ("profile_data_prefix must set when using cspgo.");
+ if (flag_csprofile_generate || flag_csprofile_use)
+ {
+ int ret = true;
+ if (!profile_data_prefix)
+ {
+ error ("pgo profile path must set when using cspgo.");
+ ret = false;
+ }
- if (!csprofile_data_prefix)
- error ("csprofile_data_prefix must set when using cspgo.");
+ if (!csprofile_data_prefix)
+ {
+ error ("cspgo profile path must set when using cspgo.");
+ ret = false;
+ }
- if (!flag_cfgo_profile_use)
- error ("cspgo must used with cfgo-pgo.");
+ if (!(flag_cfgo_profile_use || flag_profile_use))
+ {
+ error ("cspgo must used with cfgo-pgo or pgo.");
+ ret = false;
+ }
- /* Just compare canonical pathnames. */
- char* cfgo_pgo_path = lrealpath (profile_data_prefix);
- char* cfgo_cspgo_path = lrealpath (csprofile_data_prefix);
- bool files_differ = filename_cmp (cfgo_pgo_path, cfgo_cspgo_path);
- if (!files_differ)
- {
- error ("pgo and cspgo path must different between %s and %s",
- cfgo_pgo_path, cfgo_cspgo_path);
+ /* pgo and cspgo path must different. */
+ char* cfgo_pgo_path = lrealpath (profile_data_prefix);
+ char* cfgo_cspgo_path = lrealpath (csprofile_data_prefix);
+ bool files_differ = filename_cmp (cfgo_pgo_path, cfgo_cspgo_path);
+ if (!files_differ)
+ {
+ error ("pgo and cspgo path must different between %s and %s",
+ cfgo_pgo_path, cfgo_cspgo_path);
+ ret = false;
+ }
+ free (cfgo_pgo_path);
+ free (cfgo_cspgo_path);
+
+ return ret;
}
- free (cfgo_pgo_path);
- free (cfgo_cspgo_path);
- return 0;
+ return false;
}
+ /* The main process of cspgo is in csprofile_transform, execute does not need
+ to do anything. */
+ virtual unsigned int execute (function *) { return 0; }
}; // class pass_ipa_csprofile
--
2.25.1

View File

@ -2,7 +2,7 @@
%global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 64
%global gcc_release 65
%global _unpackaged_files_terminate_build 0
%global _performance_build 1
@ -438,6 +438,7 @@ Patch329: 0329-Fixed-work-with-loops-in-process_complex_cond.patch
Patch330: 0330-bugfix-fix-typo-error.patch
Patch331: 0331-fix-function-missing-return-value.patch
Patch332: 0332-Bugfix-Can-not-find-fdata-file.patch
Patch333: 0333-CSPGO-Update-the-gate-of-cspgo.patch
# Part 1001-1999
%ifarch sw_64
@ -1556,6 +1557,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
%patch -P330 -p1
%patch -P331 -p1
%patch -P332 -p1
%patch -P333 -p1
%ifarch sw_64
%patch -P1001 -p1
@ -4179,6 +4181,12 @@ end
%doc rpm.doc/changelogs/libcc1/ChangeLog*
%changelog
* Mon Dec 30 2024 liyancheng <412998149@qq.com> - 12.3.1-65
- Type:Bugfix
- ID:NA
- SUG:NA
- DESC:Update the gate of cspgo.
* Mon Dec 30 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-64
- Type:Bugfix
- ID:NA