summaryrefslogtreecommitdiff
path: root/0096-Bugfix-Autofdo-use-PMU-sampling-set-num-eauals-den.patch
blob: 20cf27b093ef9c242126da3133ed08b5a00f7dce (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
From 06e86b362f74ba0706fb5d8377f78d24b658c300 Mon Sep 17 00:00:00 2001
From: zhenyu--zhao_admin <zhaozhenyu17@huawei.com>
Date: Sat, 18 May 2024 12:22:23 +0800
Subject: [PATCH] [Bugfix] Autofdo use PMU sampling set num eauals den

---
 gcc/final.cc    | 2 +-
 gcc/tree-cfg.cc | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/final.cc b/gcc/final.cc
index f66c9d155..e4bfceabc 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -4604,7 +4604,7 @@ dump_profile_to_elf_sections ()
   /* Return if no feedback data.    */
   if (!flag_profile_use && !flag_auto_profile)
     {
-      error ("-fauto-bolt should use with -profile-use or -fauto-profile");
+      error ("-fauto-bolt should use with -fprofile-use or -fauto-profile");
       return;
     }
   
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 05fc45147..48b52f785 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -9741,6 +9741,14 @@ execute_fixup_cfg (void)
   /* Same scaling is also done by ipa_merge_profiles.  */
   profile_count num = node->count;
   profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
+  /* When autofdo uses PMU as the sampling unit, the number of
+     node can not be obtained directly, sometimes it will be zero,
+     but the execution number for function should at least be 1. We
+     set num be den here to make sure the num will not decrease.  */
+  if (num == profile_count::zero ().afdo () && den.quality () == profile_quality::AFDO)
+    {
+      num = den;
+    }
   bool scale = num.initialized_p () && !(num == den);
   auto_bitmap dce_ssa_names;
 
-- 
2.33.0