summaryrefslogtreecommitdiff
path: root/0327-Bugfix-Adjust-the-same-gate-to-use-struct-option.patch
blob: 6fd98eccfd36b6c27fda58bfcf2b09e198d56e53 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
From 861ddfd90d86215a573a7614f49d572f1e03be6f Mon Sep 17 00:00:00 2001
From: huang-xiaoquan <huangxiaoquan1@huawei.com>
Date: Mon, 16 Dec 2024 11:34:06 +0800
Subject: [PATCH] [Bugfix] Adjust the same gate to use struct option

---
 gcc/gimple-ssa-warn-access.cc | 7 ++++++-
 gcc/ipa-free-lang-data.cc     | 5 +++--
 gcc/symbol-summary.h          | 8 +++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index a24645783..3d80590ee 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -56,6 +56,9 @@
 #include "attr-fnspec.h"
 #include "pointer-query.h"
 
+/* Check whether in C language or LTO with only C language.  */
+extern bool lang_c_p (void);
+
 /* Return true if tree node X has an associated location.  */
 
 static inline location_t
@@ -2198,7 +2201,9 @@ pass_waccess::gate (function *)
      In pass waccess, it will traverse all SSA and cause ICE
      when handling these unused SSA.  So temporarily disable
      pass waccess when enable structure optimizations.  */
-  if (flag_ipa_struct_reorg)
+  if (optimize >= 3 && flag_ipa_struct_reorg && !seen_error ()
+      && flag_lto_partition == LTO_PARTITION_ONE && lang_c_p ()
+      && (in_lto_p || flag_whole_program))
     return false;
 
   return (warn_free_nonheap_object
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index 801e95cea..17e3f43b3 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -108,8 +108,9 @@ fld_simplified_type_name (tree type)
   /* Simplify type will cause that struct A and struct A within
      struct B are different type pointers, so skip it in structure
      optimizations.  */
-  if (flag_ipa_struct_reorg && lang_c_p ()
-      && flag_lto_partition == LTO_PARTITION_ONE)
+  if (optimize >= 3 && flag_ipa_struct_reorg && !seen_error ()
+      && flag_lto_partition == LTO_PARTITION_ONE && lang_c_p ()
+      && (in_lto_p || flag_whole_program))
     return TYPE_NAME (type);
 
   if (!TYPE_NAME (type) || TREE_CODE (TYPE_NAME (type)) != TYPE_DECL)
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index 4f896f4e4..06a1c7fff 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_SYMBOL_SUMMARY_H
 #define GCC_SYMBOL_SUMMARY_H
 
+#include "diagnostic.h"
+/* Check whether in C language or LTO with only C language.  */
+extern bool lang_c_p (void);
+
 /* Base class for function_summary and fast_function_summary classes.  */
 
 template <class T>
@@ -109,7 +113,9 @@ protected:
 			     : m_allocator.allocate ();
     /* In structure optimizatons, we call memset to ensure that
        the allocated memory is initialized to 0.  */
-    if (flag_ipa_struct_reorg)
+    if (optimize >= 3 && flag_ipa_struct_reorg && !seen_error ()
+	&& flag_lto_partition == LTO_PARTITION_ONE && lang_c_p ()
+	&& (in_lto_p || flag_whole_program))
       memset (allocated, 0, sizeof (T));
     return allocated;
   }
-- 
2.33.0