!519 [CSPGO] fix bugs when using cspgo
From: @li-yancheng Reviewed-by: @huang-xiaoquan Signed-off-by: @huang-xiaoquan
This commit is contained in:
commit
d045a99760
140
0319-CSPGO-fix-bugs-when-using-cspgo.patch
Normal file
140
0319-CSPGO-fix-bugs-when-using-cspgo.patch
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
From 610470b1892213afd4ddcf83862667c758724872 Mon Sep 17 00:00:00 2001
|
||||||
|
From: liyancheng <412998149@qq.com>
|
||||||
|
Date: Wed, 4 Dec 2024 16:25:01 +0800
|
||||||
|
Subject: [PATCH] [CSPGO] fix bugs when using cspgo
|
||||||
|
|
||||||
|
---
|
||||||
|
gcc/opts.cc | 36 ++++++++++++++++++++++++++----------
|
||||||
|
gcc/tree-profile.cc | 20 ++++++++++++++++++++
|
||||||
|
2 files changed, 46 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/gcc/opts.cc b/gcc/opts.cc
|
||||||
|
index 6ca9dde7e..2433ace06 100644
|
||||||
|
--- a/gcc/opts.cc
|
||||||
|
+++ b/gcc/opts.cc
|
||||||
|
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
#include "diagnostic-color.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "selftest.h"
|
||||||
|
+#include "ai4c-infer.h"
|
||||||
|
|
||||||
|
/* In this file all option sets are explicit. */
|
||||||
|
#undef OPTION_SET_P
|
||||||
|
@@ -3086,17 +3087,28 @@ common_handle_option (struct gcc_options *opts,
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_fcfgo_profile_use_:
|
||||||
|
+ opts->x_profile_data_prefix = xstrdup (arg);
|
||||||
|
+ opts->x_flag_profile_use = true;
|
||||||
|
+ value = true;
|
||||||
|
/* No break here - do -fcfgo-profile-use processing. */
|
||||||
|
/* FALLTHRU */
|
||||||
|
case OPT_fcfgo_profile_use:
|
||||||
|
- value = true;
|
||||||
|
- if (value)
|
||||||
|
+ if (get_optimize_decision_from_ai4c ())
|
||||||
|
{
|
||||||
|
+ value = true;
|
||||||
|
enable_cfgo_optimizations (opts, opts_set, value);
|
||||||
|
SET_OPTION_IF_UNSET (opts, opts_set, flag_cfgo_profile_use, value);
|
||||||
|
+ /* Enable orig fdo optimizations. */
|
||||||
|
+ enable_fdo_optimizations (opts, opts_set, value);
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_reorder_functions,
|
||||||
|
+ value);
|
||||||
|
+ /* Indirect call profiling should do all useful transformations
|
||||||
|
+ speculative devirtualization does. */
|
||||||
|
+ if (opts->x_flag_value_profile_transformations)
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_devirtualize_speculatively,
|
||||||
|
+ false);
|
||||||
|
}
|
||||||
|
- /* No break here - do -fprofile-use processing. */
|
||||||
|
- /* FALLTHRU */
|
||||||
|
+ break;
|
||||||
|
case OPT_fprofile_use_:
|
||||||
|
opts->x_profile_data_prefix = xstrdup (arg);
|
||||||
|
opts->x_flag_profile_use = true;
|
||||||
|
@@ -3116,10 +3128,10 @@ common_handle_option (struct gcc_options *opts,
|
||||||
|
|
||||||
|
case OPT_fcfgo_csprofile_use_:
|
||||||
|
opts->x_csprofile_data_prefix = xstrdup (arg);
|
||||||
|
- value = true;
|
||||||
|
/* No break here - do -fcfgo-csprofile-use processing. */
|
||||||
|
/* FALLTHRU */
|
||||||
|
case OPT_fcfgo_csprofile_use:
|
||||||
|
+ value = get_optimize_decision_from_ai4c ();
|
||||||
|
SET_OPTION_IF_UNSET (opts, opts_set, flag_csprofile_use, value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
@@ -3155,18 +3167,22 @@ common_handle_option (struct gcc_options *opts,
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_fcfgo_profile_generate_:
|
||||||
|
+ opts->x_profile_data_prefix = xstrdup (arg);
|
||||||
|
+ value = true;
|
||||||
|
/* No break here - do -fcfgo-profile-generate processing. */
|
||||||
|
/* FALLTHRU */
|
||||||
|
case OPT_fcfgo_profile_generate:
|
||||||
|
- value = true;
|
||||||
|
- if (value)
|
||||||
|
+ if (get_optimize_decision_from_ai4c ())
|
||||||
|
{
|
||||||
|
enable_cfgo_optimizations (opts, opts_set, value);
|
||||||
|
SET_OPTION_IF_UNSET (opts, opts_set, flag_cfgo_profile_generate,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
- /* No break here - do -fprofile-generate processing. */
|
||||||
|
- /* FALLTHRU */
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, profile_arc_flag, value);
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_profile_values, value);
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_inline_functions, value);
|
||||||
|
+ SET_OPTION_IF_UNSET (opts, opts_set, flag_ipa_bit_cp, value);
|
||||||
|
+ break;
|
||||||
|
case OPT_fprofile_generate_:
|
||||||
|
opts->x_profile_data_prefix = xstrdup (arg);
|
||||||
|
value = true;
|
||||||
|
@@ -3181,10 +3197,10 @@ common_handle_option (struct gcc_options *opts,
|
||||||
|
|
||||||
|
case OPT_fcfgo_csprofile_generate_:
|
||||||
|
opts->x_csprofile_data_prefix = xstrdup (arg);
|
||||||
|
- value = true;
|
||||||
|
/* No break here - do -fcfgo-csprofile-generate processing. */
|
||||||
|
/* FALLTHRU */
|
||||||
|
case OPT_fcfgo_csprofile_generate:
|
||||||
|
+ value = get_optimize_decision_from_ai4c ();
|
||||||
|
SET_OPTION_IF_UNSET (opts, opts_set, flag_csprofile_generate, value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
|
||||||
|
index aa3a2b3a9..ace1fe31c 100644
|
||||||
|
--- a/gcc/tree-profile.cc
|
||||||
|
+++ b/gcc/tree-profile.cc
|
||||||
|
@@ -1114,6 +1114,26 @@ public:
|
||||||
|
to do anything. */
|
||||||
|
virtual unsigned int execute (function *)
|
||||||
|
{
|
||||||
|
+ if (!profile_data_prefix)
|
||||||
|
+ error ("profile_data_prefix must set when using cspgo.");
|
||||||
|
+
|
||||||
|
+ if (!csprofile_data_prefix)
|
||||||
|
+ error ("csprofile_data_prefix must set when using cspgo.");
|
||||||
|
+
|
||||||
|
+ if (!flag_cfgo_profile_use)
|
||||||
|
+ error ("cspgo must used with cfgo-pgo.");
|
||||||
|
+
|
||||||
|
+ /* 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);
|
||||||
|
+ }
|
||||||
|
+ free (cfgo_pgo_path);
|
||||||
|
+ free (cfgo_cspgo_path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
10
gcc.spec
10
gcc.spec
@ -2,7 +2,7 @@
|
|||||||
%global gcc_major 12
|
%global gcc_major 12
|
||||||
# Note, gcc_release must be integer, if you want to add suffixes to
|
# Note, gcc_release must be integer, if you want to add suffixes to
|
||||||
# %%{release}, append them after %%{gcc_release} on Release: line.
|
# %%{release}, append them after %%{gcc_release} on Release: line.
|
||||||
%global gcc_release 54
|
%global gcc_release 55
|
||||||
|
|
||||||
%global _unpackaged_files_terminate_build 0
|
%global _unpackaged_files_terminate_build 0
|
||||||
%global _performance_build 1
|
%global _performance_build 1
|
||||||
@ -424,6 +424,7 @@ Patch315: 0315-Bugfix-Add-no-var-recored-check-for-ssa_name-in-stru.patch
|
|||||||
Patch316: 0316-Use-ai-ability-to-guide-optimization.patch
|
Patch316: 0316-Use-ai-ability-to-guide-optimization.patch
|
||||||
Patch317: 0317-Bugfix-set-default-value-when-tune_native-is-NULL.patch
|
Patch317: 0317-Bugfix-set-default-value-when-tune_native-is-NULL.patch
|
||||||
Patch318: 0318-add-flag-flto-try.patch
|
Patch318: 0318-add-flag-flto-try.patch
|
||||||
|
Patch319: 0319-CSPGO-fix-bugs-when-using-cspgo.patch
|
||||||
|
|
||||||
# Part 1001-1999
|
# Part 1001-1999
|
||||||
%ifarch sw_64
|
%ifarch sw_64
|
||||||
@ -1528,6 +1529,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
|||||||
%patch -P316 -p1
|
%patch -P316 -p1
|
||||||
%patch -P317 -p1
|
%patch -P317 -p1
|
||||||
%patch -P318 -p1
|
%patch -P318 -p1
|
||||||
|
%patch -P319 -p1
|
||||||
|
|
||||||
%ifarch sw_64
|
%ifarch sw_64
|
||||||
%patch -P1001 -p1
|
%patch -P1001 -p1
|
||||||
@ -4150,6 +4152,12 @@ end
|
|||||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Dec 04 2024 liyancheng <412998149@qq.com> - 12.3.1-55
|
||||||
|
- Type:Bugfix
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC: Fix bugs for cspgo.
|
||||||
|
|
||||||
* Wed Dec 04 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-54
|
* Wed Dec 04 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-54
|
||||||
- Type:Sync
|
- Type:Sync
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user