diff --git a/0358-Avoid-doing-sfc-with-struct_split-and-compressing-de.patch b/0358-Avoid-doing-sfc-with-struct_split-and-compressing-de.patch new file mode 100644 index 0000000000000000000000000000000000000000..66438ca5ef582130b8863f93b59c43fd35a1002c --- /dev/null +++ b/0358-Avoid-doing-sfc-with-struct_split-and-compressing-de.patch @@ -0,0 +1,136 @@ +From 63b3db6e1f3e4aba90d76780fb64f6875c5dd2ab Mon Sep 17 00:00:00 2001 +From: huzife <634763349@qq.com> +Date: Wed, 26 Feb 2025 01:24:45 +0800 +Subject: [PATCH] Avoid doing sfc with struct_split and compressing dead fields + +--- + gcc/ipa-struct-reorg/ipa-struct-reorg.cc | 13 ++++++-- + .../gcc.dg/struct/sfc-shadow_dead_field.c | 31 ++++++++++++++++++ + gcc/testsuite/gcc.dg/struct/sfc_dead_field.c | 32 +++++++++++++++++++ + 3 files changed, 74 insertions(+), 2 deletions(-) + create mode 100644 gcc/testsuite/gcc.dg/struct/sfc-shadow_dead_field.c + create mode 100644 gcc/testsuite/gcc.dg/struct/sfc_dead_field.c + +diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +index f2660c952..fcc26d6a4 100644 +--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc ++++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +@@ -8970,7 +8970,8 @@ void + ipa_struct_reorg::classify_fields (fc_type_info *info) + { + for (auto *srf : info->type->fields) +- info->record_field_class (srf); ++ if (!srf->dead_field_p ()) ++ info->record_field_class (srf); + + if (dump_file && (dump_flags & TDF_DETAILS)) + { +@@ -8997,6 +8998,10 @@ ipa_struct_reorg::find_static_fc_fields (fc_type_info *info) + + for (auto *srf : info->type->fields) + { ++ /* Skip dead field. */ ++ if (srf->dead_field_p ()) ++ continue; ++ + /* Avoid compressing non-integer type. */ + if (TREE_CODE (srf->fieldtype) != INTEGER_TYPE) + continue; +@@ -10064,7 +10069,8 @@ ipa_struct_reorg::execute (unsigned int opt) + check_and_prune_struct_for_pointer_compression (); + if (opt >= SEMI_RELAYOUT) + check_and_prune_struct_for_semi_relayout (); +- if (flag_ipa_struct_sfc) ++ /* Avoid doing static field compression in STRUCT_SPLIT. */ ++ if (opt >= STRUCT_REORDER_FIELDS && flag_ipa_struct_sfc) + check_and_prune_struct_for_field_compression (); + ret = rewrite_functions (); + } +@@ -10148,6 +10154,9 @@ public: + if (level >= STRUCT_REORDER_FIELDS) + ret = ipa_struct_reorg ().execute (level); + ++ if (ret & TODO_remove_functions) ++ symtab->remove_unreachable_nodes (dump_file); ++ + if (level >= COMPLETE_STRUCT_RELAYOUT) + { + /* Preserved for backward compatibility. +diff --git a/gcc/testsuite/gcc.dg/struct/sfc-shadow_dead_field.c b/gcc/testsuite/gcc.dg/struct/sfc-shadow_dead_field.c +new file mode 100644 +index 000000000..dbe8633cc +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/struct/sfc-shadow_dead_field.c +@@ -0,0 +1,31 @@ ++/* { dg-do compile } */ ++/* { dg-additional-options "-fipa-struct-reorg=3" } */ ++ ++#include ++#include ++ ++struct arc { ++ unsigned long a; ++ unsigned long b; ++}; ++typedef struct arc arc_t; ++ ++#define MAX 16 ++ ++int main() { ++ arc_t* arcs = (arc_t*)calloc(MAX, sizeof(arc_t)); ++ for (int i = 0; i < MAX; i++) { ++ arcs[i].a = i; ++ arcs[i].b = i; ++ } ++ ++ for (int i = 0; i < MAX; i++) { ++ if (arcs[i].b != i) ++ abort (); ++ } ++ ++ return 0; ++} ++ ++ ++/* { dg-final { scan-ipa-dump "\\\[field compress\\\] Fail finding static fc fields" "struct_reorg" } } */ +diff --git a/gcc/testsuite/gcc.dg/struct/sfc_dead_field.c b/gcc/testsuite/gcc.dg/struct/sfc_dead_field.c +new file mode 100644 +index 000000000..ccd8339ab +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/struct/sfc_dead_field.c +@@ -0,0 +1,32 @@ ++/* { dg-do compile } */ ++/* { dg-additional-options "-fipa-struct-reorg=3" } */ ++ ++#include ++#include ++ ++struct arc { ++ unsigned long a; ++ unsigned long b; ++}; ++typedef struct arc arc_t; ++ ++#define MAX 16 ++ ++int main() { ++ arc_t* arcs = (arc_t*)calloc(MAX, sizeof(arc_t)); ++ for (int i = 0; i < MAX; i++) { ++ arcs[i].a = 10000; ++ arcs[i].b = 10; ++ } ++ ++ for (int i = 0; i < MAX; i++) { ++ if (arcs[i].a != 10000) ++ abort (); ++ } ++ ++ return 0; ++} ++ ++/* { dg-final { scan-ipa-dump "\\\[field compress\\\] Found a static compression field: a, max_value = 10000" "struct_reorg" } } */ ++/* { dg-final { scan-ipa-dump "\\\[field compress\\\] Found a static compression field: b" "struct_reorg" { xfail *-*-* } } } */ ++/* { dg-final { scan-ipa-dump "size : 2" "struct_reorg" } } */ +-- +2.33.0 + diff --git a/gcc.spec b/gcc.spec index 940b51688c13604f01b4aa55541ac4dc90c6d795..7d22b87db4e820642c2dad435820abd0f870511f 100644 --- a/gcc.spec +++ b/gcc.spec @@ -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 74 +%global gcc_release 75 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -463,6 +463,7 @@ Patch354: 0354-Fix-for-hip11-and-hip10c-addrcost_table.patch Patch355: 0355-Fix-errors-in-ipa-struct-sfc-IBMY84-IBN2JO-IBN42Q.patch Patch356: 0356-add-llc-allocate-feature.patch Patch357: 0357-Enhancing-BOLT-Optimization-with-AI.patch +Patch358: 0358-Avoid-doing-sfc-with-struct_split-and-compressing-de.patch # Part 1001-1999 %ifarch sw_64 @@ -1606,6 +1607,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P355 -p1 %patch -P356 -p1 %patch -P357 -p1 +%patch -P358 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4243,6 +4245,12 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Thu Feb 27 2025 huzife <634763349@qq.com> - 12.3.1-75 +- Type:Bugfix +- ID:NA +- SUG:NA +- DESC:Avoid doing sfc with struct_split and compressing dead fields + * Mon Feb 24 2025 chenhong - 12.3.1-74 - Type:Sync - ID:NA