Projects
openEuler:22.03:LTS:LoongArch
gcc
_service:tar_scm_kernel_repo:0044-Struct-Reorg-...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm_kernel_repo:0044-Struct-Reorg-Type-simplify-limitation-when-in-struct.patch of Package gcc
From b66a843505f32685f428c502f1a88e0f681b4acd Mon Sep 17 00:00:00 2001 From: eastb233 <xiezhiheng@huawei.com> Date: Thu, 15 Sep 2022 17:57:00 +0800 Subject: [PATCH] [Struct Reorg] Type simplify limitation when in structure optimizaiton When enable structure optimization, we should not simplify TYPE NODE. But now we unconditionally skip the simplification under structure optimization regardless of whether it takes effect. So add the same limitation as the optimization has. In order to adapt to the current code, use flag_ipa_reorder_fields instead of flag_ipa_struct_layout. --- gcc/ipa-struct-reorg/ipa-struct-reorg.c | 72 ++++++++++++------------- gcc/tree.c | 13 ++++- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c index 8d3da35400d..54c20ca3f33 100644 --- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c +++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c @@ -104,6 +104,42 @@ along with GCC; see the file COPYING3. If not see #define VOID_POINTER_P(type) (POINTER_TYPE_P (type) && VOID_TYPE_P (TREE_TYPE (type))) +/* Check whether in C language or LTO with only C language. */ +bool +lang_c_p (void) +{ + const char *language_string = lang_hooks.name; + + if (!language_string) + { + return false; + } + + if (lang_GNU_C ()) + { + return true; + } + else if (strcmp (language_string, "GNU GIMPLE") == 0) // for LTO check + { + unsigned i = 0; + tree t = NULL_TREE; + + FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, t) + { + language_string = TRANSLATION_UNIT_LANGUAGE (t); + if (language_string == NULL + || strncmp (language_string, "GNU C", 5) + || (language_string[5] != '\0' + && !(ISDIGIT (language_string[5])))) + { + return false; + } + } + return true; + } + return false; +} + namespace { using namespace struct_reorg; @@ -163,42 +199,6 @@ handled_type (tree type) return false; } -/* Check whether in C language or LTO with only C language. */ -bool -lang_c_p (void) -{ - const char *language_string = lang_hooks.name; - - if (!language_string) - { - return false; - } - - if (lang_GNU_C ()) - { - return true; - } - else if (strcmp (language_string, "GNU GIMPLE") == 0) // for LTO check - { - unsigned i = 0; - tree t = NULL_TREE; - - FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, t) - { - language_string = TRANSLATION_UNIT_LANGUAGE (t); - if (language_string == NULL - || strncmp (language_string, "GNU C", 5) - || (language_string[5] != '\0' - && !(ISDIGIT (language_string[5])))) - { - return false; - } - } - return true; - } - return false; -} - /* Get the number of pointer layers. */ int diff --git a/gcc/tree.c b/gcc/tree.c index c2075d73586..84a440b3576 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -128,6 +128,9 @@ const char *const tree_code_class_strings[] = /* obstack.[ch] explicitly declined to prototype this. */ extern int _obstack_allocated_p (struct obstack *h, void *obj); +/* Check whether in C language or LTO with only C language. */ +extern bool lang_c_p (void); + /* Statistics-gathering stuff. */ static uint64_t tree_code_counts[MAX_TREE_CODES]; @@ -5219,7 +5222,10 @@ 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_reorder_fields || flag_ipa_struct_reorg) + if ((flag_ipa_reorder_fields || flag_ipa_struct_reorg) + && lang_c_p () + && flag_lto_partition == LTO_PARTITION_ONE + && (in_lto_p || flag_whole_program)) return TYPE_NAME (type); if (!TYPE_NAME (type) || TREE_CODE (TYPE_NAME (type)) != TYPE_DECL) @@ -5463,7 +5469,10 @@ fld_simplified_type (tree t, class free_lang_data_d *fld) /* 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_reorder_fields || flag_ipa_struct_reorg) + if ((flag_ipa_reorder_fields || flag_ipa_struct_reorg) + && lang_c_p () + && flag_lto_partition == LTO_PARTITION_ONE + && (in_lto_p || flag_whole_program)) return t; if (POINTER_TYPE_P (t)) return fld_incomplete_type_of (t, fld); -- 2.21.0.windows.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.