summaryrefslogtreecommitdiff
path: root/0100-PGO-kernel-Add-fkernel-pgo-option-to-support-PGO-ker.patch
blob: a77c07286627883b373509c5632e0a9090ce014d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 90d3ef0637c66045eeab78ccf04e9ff51b9b451a Mon Sep 17 00:00:00 2001
From: xiongzhou4 <xiongzhou4@huawei.com>
Date: Thu, 1 Jun 2023 09:28:27 +0800
Subject: [PATCH 5/5] [PGO kernel] Add fkernel-pgo option to support PGO kernel
 compilation.

If specified, disable TLS setting of instrumentation variables in
gcc/tree-profile.c, as kernel does not support TLS.
---
 gcc/common.opt     | 4 ++++
 gcc/tree-profile.c | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 238c97db8..6f0ed7cea 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2302,6 +2302,10 @@ fprofile-generate=
 Common Joined RejectNegative
 Enable common options for generating profile info for profile feedback directed optimizations, and set -fprofile-dir=.
 
+fkernel-pgo
+Common Report Var(flag_kernel_pgo) Optimization Init(0)
+Disable TLS setting of instrumentation variables to support PGO kernel compilation in -fprofile-generate, as kernel does not support TLS.
+
 fprofile-partial-training
 Common Report Var(flag_profile_partial_training) Optimization
 Do not assume that functions never executed during the train run are cold.
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 6c0838261..924817472 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -105,7 +105,9 @@ init_ic_make_global_vars (void)
   DECL_ARTIFICIAL (ic_tuple_var) = 1;
   DECL_INITIAL (ic_tuple_var) = NULL;
   DECL_EXTERNAL (ic_tuple_var) = 1;
-  if (targetm.have_tls)
+  /* Disable TLS setting when compiling kernel in -fprofile-generate,
+     as kernel does not support TLS. */
+  if (targetm.have_tls && !flag_kernel_pgo)
     set_decl_tls_model (ic_tuple_var, decl_default_tls_model (ic_tuple_var));
 }
 
-- 
2.33.0