82 lines
3.0 KiB
Diff
82 lines
3.0 KiB
Diff
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
|
|
|