diff --git a/0357-struct-reorg-disable-malloc-support-when-struct_layo.patch b/0357-struct-reorg-disable-malloc-support-when-struct_layo.patch new file mode 100644 index 0000000000000000000000000000000000000000..2904a9a099a2522f5627485e3bdb24934ff79ae2 --- /dev/null +++ b/0357-struct-reorg-disable-malloc-support-when-struct_layo.patch @@ -0,0 +1,137 @@ +From b10a7d82b6a87048481a17b2f49e01b4fc0e35c3 Mon Sep 17 00:00:00 2001 +From: liyancheng <412998149@qq.com> +Date: Sun, 9 Mar 2025 16:04:31 +0800 +Subject: [PATCH] [struct-reorg] disable malloc support when + struct_layout_optimize_level > 1 + +The struct-reorg opt does not support malloc well, +so disable it for stability when struct_layout_optimize_level +greater than 1. +--- + gcc/ipa-struct-reorg/ipa-struct-reorg.cc | 1 - + gcc/testsuite/gcc.dg/struct/dfe_ptr_ptr.c | 2 +- + .../gcc.dg/struct/rf_create_fields_bug.c | 4 +-- + gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c | 4 +-- + .../gcc.dg/struct/rf_rewrite_cond_more_cmp.c | 6 ++-- + .../gcc.dg/struct/sfc-shadow_malloc.c | 28 ------------------- + 6 files changed, 8 insertions(+), 37 deletions(-) + delete mode 100644 gcc/testsuite/gcc.dg/struct/sfc-shadow_malloc.c + +diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +index fcc26d6a4..98ba8fb12 100644 +--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc ++++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +@@ -4041,7 +4041,6 @@ ipa_struct_reorg::handled_allocation_stmt (gimple *stmt) + { + if ((current_layout_opt_level & STRUCT_REORDER_FIELDS) + && (gimple_call_builtin_p (stmt, BUILT_IN_REALLOC) +- || gimple_call_builtin_p (stmt, BUILT_IN_MALLOC) + || gimple_call_builtin_p (stmt, BUILT_IN_CALLOC))) + return true; + if ((current_layout_opt_level == COMPLETE_STRUCT_RELAYOUT +diff --git a/gcc/testsuite/gcc.dg/struct/dfe_ptr_ptr.c b/gcc/testsuite/gcc.dg/struct/dfe_ptr_ptr.c +index b91efe10f..3cb473663 100644 +--- a/gcc/testsuite/gcc.dg/struct/dfe_ptr_ptr.c ++++ b/gcc/testsuite/gcc.dg/struct/dfe_ptr_ptr.c +@@ -47,7 +47,7 @@ arc_t **ap = NULL; + int + main () + { +- ap = (arc_t**) malloc(MAX * sizeof(arc_t*)); ++ ap = (arc_t**) calloc(MAX, sizeof(arc_t*)); + (*ap)[0].id = 300; + return 0; + } +diff --git a/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c b/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c +index 7d7641f01..91ba80891 100644 +--- a/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c ++++ b/gcc/testsuite/gcc.dg/struct/rf_create_fields_bug.c +@@ -74,9 +74,9 @@ main() + { + abort (); + } +- ap = (arc_t**) malloc(MAX * sizeof(arc_t*)); ++ ap = (arc_t**) calloc(MAX, sizeof(arc_t*)); + (*ap)[0].id = 300; + return 0; + } + +-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +\ No newline at end of file ++/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +diff --git a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c +index 4df79e4f0..9d396e39a 100644 +--- a/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c ++++ b/gcc/testsuite/gcc.dg/struct/rf_ptr_ptr.c +@@ -47,9 +47,9 @@ arc_t **ap = NULL; + int + main () + { +- ap = (arc_t**) malloc(MAX * sizeof(arc_t*)); ++ ap = (arc_t**) calloc(MAX, sizeof(arc_t*)); + (*ap)[0].id = 300; + return 0; + } + +-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +\ No newline at end of file ++/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c +index 5ad206433..ca8333601 100644 +--- a/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c ++++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_cond_more_cmp.c +@@ -44,8 +44,8 @@ struct arc + int + main() + { +- arc_p **ap = (arc_p**) malloc(1 * sizeof(arc_p*)); +- arc_p **arcs_pointer_sorted = (arc_p**) malloc(1 * sizeof(arc_p*)); ++ arc_p **ap = (arc_p**) calloc(1, sizeof(arc_p*)); ++ arc_p **arcs_pointer_sorted = (arc_p**) calloc(1, sizeof(arc_p*)); + arcs_pointer_sorted[0] = (arc_p*) calloc (1, sizeof(arc_p)); + + if (arcs_pointer_sorted >= ap) +@@ -55,4 +55,4 @@ main() + return 0; + } + +-/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +\ No newline at end of file ++/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "struct_reorg" } } */ +diff --git a/gcc/testsuite/gcc.dg/struct/sfc-shadow_malloc.c b/gcc/testsuite/gcc.dg/struct/sfc-shadow_malloc.c +deleted file mode 100644 +index e709f7b25..000000000 +--- a/gcc/testsuite/gcc.dg/struct/sfc-shadow_malloc.c ++++ /dev/null +@@ -1,28 +0,0 @@ +-/* { dg-do compile } */ +- +-#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*)malloc(MAX * sizeof(arc_t)); +- for (int i = 0; i < MAX; i++) { +- arcs[i].a = 0; +- } +- for (int i = 0; i < MAX; i++) { +- arcs[i].a = i; +- arcs[i].b = i; +- } +- printf("%d, %d\n", arcs[10].a, arcs[10].b); +- +- return 0; +-} +- +-/* { dg-final { scan-ipa-dump "\\\[field compress\\\] Fail finding shadow field" "struct_reorg" } } */ +-- +2.33.0 + diff --git a/gcc.spec b/gcc.spec index 9f1863d9c69a5a045743d29353436e8823bada0c..19c269ff8a1d44e14f8ae32e01e788f6066393e4 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 73 +%global gcc_release 74 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -462,6 +462,7 @@ Patch353: 0353-Add-hip10a-machine-discription.patch Patch354: 0354-Fix-for-hip11-and-hip10c-addrcost_table.patch Patch355: 0355-Fix-errors-in-ipa-struct-sfc-IBMY84-IBN2JO-IBN42Q.patch Patch356: 0356-Avoid-doing-sfc-with-struct_split-and-compressing-de.patch +Patch357: 0357-struct-reorg-disable-malloc-support-when-struct_layo.patch # Part 1001-1999 %ifarch sw_64 @@ -1604,6 +1605,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P354 -p1 %patch -P355 -p1 %patch -P356 -p1 +%patch -P357 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4231,6 +4233,10 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Sun Mar 09 2025 liyancheng <412998149@qq.com> - 12.3.1-74 +- Type:Bugfix +- DESC: disable malloc support when struct_layout_optimize_level > 1 + * Thu Feb 27 2025 huzife <634763349@qq.com> - 12.3.1-73 - Type:Bugfix - ID:NA