89 lines
2.7 KiB
Diff
89 lines
2.7 KiB
Diff
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
|
|
|