[Bugfix] Adjust the same gate to use struct option.

This commit is contained in:
huang-xiaoquan 2024-12-16 14:56:07 +08:00
parent 89ad5ae069
commit f14abd9e8f
2 changed files with 90 additions and 1 deletions

View File

@ -0,0 +1,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

View File

@ -2,7 +2,7 @@
%global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 59
%global gcc_release 60
%global _unpackaged_files_terminate_build 0
%global _performance_build 1
@ -432,6 +432,7 @@ Patch323: 0323-Bugfix-replace-tmp-pattern-split.patch
Patch324: 0324-bugfix-fix-vector-costs-for-hip09.patch
Patch325: 0325-gcc-opts-common.cc-Fix-build-with-clang.patch
Patch326: 0326-BUGFIX-Fix-build-error-on-risv_64.patch
Patch327: 0327-Bugfix-Adjust-the-same-gate-to-use-struct-option.patch
# Part 1001-1999
%ifarch sw_64
@ -1544,6 +1545,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
%patch -P324 -p1
%patch -P325 -p1
%patch -P326 -p1
%patch -P327 -p1
%ifarch sw_64
%patch -P1001 -p1
@ -4167,6 +4169,12 @@ end
%doc rpm.doc/changelogs/libcc1/ChangeLog*
%changelog
* Mon Dec 16 2024 huang-xiaoquan <huangxiaoquan1@huawei.com> - 12.3.1-60
- Type:Bugfix
- ID:NA
- SUG:NA
- DESC:Adjust the same gate to use struct option.
* Wed Dec 11 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-59
- Type:Sync
- ID:NA