diff --git a/0381-dfc-Fix-error-in-function-wholeaccess.patch b/0381-dfc-Fix-error-in-function-wholeaccess.patch new file mode 100644 index 0000000000000000000000000000000000000000..9adfa569e26d2d7c69c0185e8bb32a0f16fd0830 --- /dev/null +++ b/0381-dfc-Fix-error-in-function-wholeaccess.patch @@ -0,0 +1,87 @@ +From 6de9d3011cda914ab1fecd73f1d517cc3b82f0cb Mon Sep 17 00:00:00 2001 +From: huzife <634763349@qq.com> +Date: Fri, 23 May 2025 14:48:13 +0800 +Subject: [PATCH] [dfc] Fix error in function wholeaccess + +--- + gcc/ipa-struct-reorg/ipa-struct-reorg.cc | 32 ++++++------------- + gcc/testsuite/gcc.dg/struct/dfc_wholeaccess.c | 18 +++++++++++ + 2 files changed, 27 insertions(+), 23 deletions(-) + create mode 100644 gcc/testsuite/gcc.dg/struct/dfc_wholeaccess.c + +diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +index 851bda65c..e8a84abbd 100644 +--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc ++++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +@@ -5014,35 +5014,21 @@ ipa_struct_reorg::wholeaccess (tree expr, tree base, + if (TREE_CODE (expr) == ADDR_EXPR && TREE_OPERAND (expr, 0) == base) + return true; + +- if (!accesstype) ++ if (!accesstype || !handled_type (TREE_TYPE (expr)) || !t || !t->type) + return false; + +- if (!types_compatible_p (TREE_TYPE (expr), TREE_TYPE (accesstype))) +- return false; +- +- if (!handled_type (TREE_TYPE (expr))) +- return false; +- +- if (!t || !t->type) +- return false; +- +- tree type = TYPE_MAIN_VARIANT (t->type); ++ /* T *_1; _2 = MEM[(T *)_1]. */ + if (TREE_CODE (expr) == MEM_REF +- && POINTER_TYPE_P (TREE_TYPE (expr)) +- && POINTER_TYPE_P (accesstype) +- && POINTER_TYPE_P (TREE_TYPE (accesstype)) ++ && integer_zerop (TREE_OPERAND (expr, 1)) + && POINTER_TYPE_P (TREE_TYPE (base)) +- && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (base))) == type +- && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr))) == type +- && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (accesstype))) == type) +- return false; +- +- srtype *other_type = find_type (inner_type (TREE_TYPE (expr))); ++ && types_compatible_p (TREE_TYPE (TREE_TYPE (base)), t->type)) ++ return POINTER_TYPE_P (accesstype) ++ && types_compatible_p (TREE_TYPE (accesstype), t->type); + +- if (t == other_type) +- return true; ++ if (!types_compatible_p (TREE_TYPE (expr), TREE_TYPE (accesstype))) ++ return false; + +- return false; ++ return t == find_type (inner_type (TREE_TYPE (expr))); + } + + bool +diff --git a/gcc/testsuite/gcc.dg/struct/dfc_wholeaccess.c b/gcc/testsuite/gcc.dg/struct/dfc_wholeaccess.c +new file mode 100644 +index 000000000..60d73f0f0 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/struct/dfc_wholeaccess.c +@@ -0,0 +1,18 @@ ++/* { dg-do compile } */ ++ ++struct Type_A; ++ ++// Optimized type. ++struct Type_B { ++ int b; ++}; ++ ++__attribute__((used)) static void test() { ++ struct Type_A* a; ++ struct Type_B* b; ++ ++ // MEM[(Type_B*)a] = *b; ++ *((struct Type_B*)a) = *b; ++} ++ ++// This testsuite should be compiled successfully without ICE. +-- +2.43.0 + diff --git a/gcc.spec b/gcc.spec index 658cc868f37ad93f1904d3e48184dea122deac8a..80857d5e53c1d939debbeae00c2316cd59ba5647 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 85 +%global gcc_release 86 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -490,6 +490,7 @@ Patch377: 0377-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-namespace.patch Patch378: 0378-Add-alignment-propagation-localize-array-array-dse.patch Patch379: 0379-SVE-Add-container-restriction-for-std-find-with-sve.patch Patch380: 0380-Fix-tune-params-error-in-hip09-and-hip11.patch +Patch381: 0381-dfc-Fix-error-in-function-wholeaccess.patch # Part 1001-1999 %ifarch sw_64 @@ -1656,6 +1657,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P378 -p1 %patch -P379 -p1 %patch -P380 -p1 +%patch -P381 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4283,6 +4285,10 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Tue May 27 2025 huzife <634763349@qq.com> - 12.3.1-86 +- Type: Sync +- DESC: Sync patches from openeuler/gcc. + * Wed May 21 2025 huzife <634763349@qq.com> - 12.3.1-85 - Type: Bugfix - DESC: Fix tune params error in hip09 and hip11.