diff --git a/0321-Struct-reorg-Avoid-doing-struct-split-and-reorder_fi.patch b/0321-Struct-reorg-Avoid-doing-struct-split-and-reorder_fi.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f94975d834742ea99ca6882f3bc20106dfec51c --- /dev/null +++ b/0321-Struct-reorg-Avoid-doing-struct-split-and-reorder_fi.patch @@ -0,0 +1,192 @@ +From a96315832872aae9af8ff3f81100b21e82c94072 Mon Sep 17 00:00:00 2001 +From: liyancheng <412998149@qq.com> +Date: Sat, 7 Dec 2024 16:27:28 +0800 +Subject: [PATCH 1/2] [Struct-reorg] Avoid doing struct split and + reorder_fields together + +Rewrite between struct_split and reorder_fields is +incompatible, so avoid doing them together. +--- + gcc/ipa-struct-reorg/ipa-struct-reorg.cc | 7 +- + .../struct/rf_rewrite_problem_with_split.c | 134 ++++++++++++++++++ + gcc/testsuite/gcc.dg/struct/struct-reorg.exp | 4 + + 3 files changed, 143 insertions(+), 2 deletions(-) + create mode 100644 gcc/testsuite/gcc.dg/struct/rf_rewrite_problem_with_split.c + +diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +index b93b8a5b5..af91f15c5 100644 +--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.cc ++++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.cc +@@ -8646,8 +8646,11 @@ public: + + if (level >= COMPLETE_STRUCT_RELAYOUT) + { +- /* Preserved for backward compatibility. */ +- ret_reorg = ipa_struct_reorg ().execute (STRUCT_SPLIT); ++ /* Preserved for backward compatibility. ++ Rewrite between STRUCT_REORDER_FIELDS and STRUCT_SPLIT has unfixed ++ problem, so avoid using them together. */ ++ if (!ret) ++ ret_reorg = ipa_struct_reorg ().execute (STRUCT_SPLIT); + if (!ret_reorg) + ret_reorg = ipa_struct_reorg ().execute (COMPLETE_STRUCT_RELAYOUT); + } +diff --git a/gcc/testsuite/gcc.dg/struct/rf_rewrite_problem_with_split.c b/gcc/testsuite/gcc.dg/struct/rf_rewrite_problem_with_split.c +new file mode 100644 +index 000000000..da357ec18 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/struct/rf_rewrite_problem_with_split.c +@@ -0,0 +1,134 @@ ++/* { dg-do run } */ ++#include "stdio.h" ++#include "stdlib.h" ++#include "time.h" ++#include "string.h" ++#include "limits.h" ++#include "float.h" ++#define JOTAI_NUM_RANDS_ 25 ++const unsigned rand_primes[JOTAI_NUM_RANDS_] = {179, 103, 479, 647, 229, 37, ++271, 557, 263, 607, 18743, 50359, 21929, 48757, 98179, 12907, 52937, 64579, ++49957, 52567, 507163, 149939, 412157, 680861, 757751}; ++int next_i() { ++ int counter = 0; ++ return rand_primes[(++counter)%JOTAI_NUM_RANDS_]; ++} ++typedef unsigned long size_t; // Customize by platform. ++typedef long intptr_t; typedef unsigned long uintptr_t; ++typedef long scalar_t__; // Either arithmetic or pointer type. ++typedef int bool; ++#define false 0 ++#define true 1 ++typedef struct TYPE_2__ TYPE_1__; ++struct pci_dev {int devfn; TYPE_1__* sriov; int /*<<< orphan*/ is_physfn; }; ++struct TYPE_2__ {int offset; int stride; } ; ++int EINVAL ; ++int pci_iov_virtfn_devfn(struct pci_dev *dev, int vf_id) ++{ ++ if (!dev->is_physfn) ++ return -EINVAL; ++ return (dev->devfn + dev->sriov->offset + ++ dev->sriov->stride * vf_id) & 0xff; ++} ++int main(int argc, char *argv[]) { ++ int opt = 1; ++ switch(opt) { ++ case 0: ++ { ++ int vf_id = 100; ++ int _len_dev0 = 1; ++ struct pci_dev * dev = ++ (struct pci_dev *) malloc(_len_dev0*sizeof(struct pci_dev)); ++ for(int _i0 = 0; _i0 < _len_dev0; _i0++) { ++ dev[_i0].devfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ int _len_dev__i0__sriov0 = 1; ++ dev[_i0].sriov = ++ (struct TYPE_2__ *) malloc(_len_dev__i0__sriov0*sizeof(struct TYPE_2__)); ++ for(int _j0 = 0; _j0 < _len_dev__i0__sriov0; _j0++) { ++ dev[_i0].sriov->offset = ((-2 * (next_i()%2)) + 1) * next_i(); ++ dev[_i0].sriov->stride = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ dev[_i0].is_physfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ int benchRet = pci_iov_virtfn_devfn(dev,vf_id); ++ printf("%d\n", benchRet); ++ for(int _aux = 0; _aux < _len_dev0; _aux++) { ++ free(dev[_aux].sriov); ++ } ++ free(dev); ++ break; ++ } ++ case 1: ++ { ++ int vf_id = 255; ++ int _len_dev0 = 65025; ++ struct pci_dev * dev = (struct pci_dev *) malloc(_len_dev0*sizeof(struct pci_dev)); ++ for(int _i0 = 0; _i0 < _len_dev0; _i0++) { ++ dev[_i0].devfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ int _len_dev__i0__sriov0 = 1; ++ dev[_i0].sriov = (struct TYPE_2__ *) malloc(_len_dev__i0__sriov0*sizeof(struct TYPE_2__)); ++ for(int _j0 = 0; _j0 < _len_dev__i0__sriov0; _j0++) { ++ dev[_i0].sriov->offset = ((-2 * (next_i()%2)) + 1) * next_i(); ++ dev[_i0].sriov->stride = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ dev[_i0].is_physfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ int benchRet = pci_iov_virtfn_devfn(dev,vf_id); ++ printf("%d\n", benchRet); ++ for(int _aux = 0; _aux < _len_dev0; _aux++) { ++ free(dev[_aux].sriov); ++ } ++ free(dev); ++ break; ++ } ++ case 2: ++ { ++ int vf_id = 10; ++ int _len_dev0 = 100; ++ struct pci_dev * dev = (struct pci_dev *) malloc(_len_dev0*sizeof(struct pci_dev)); ++ for(int _i0 = 0; _i0 < _len_dev0; _i0++) { ++ dev[_i0].devfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ int _len_dev__i0__sriov0 = 1; ++ dev[_i0].sriov = (struct TYPE_2__ *) malloc(_len_dev__i0__sriov0*sizeof(struct TYPE_2__)); ++ for(int _j0 = 0; _j0 < _len_dev__i0__sriov0; _j0++) { ++ dev[_i0].sriov->offset = ((-2 * (next_i()%2)) + 1) * next_i(); ++ dev[_i0].sriov->stride = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ dev[_i0].is_physfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ int benchRet = pci_iov_virtfn_devfn(dev,vf_id); ++ printf("%d\n", benchRet); ++ for(int _aux = 0; _aux < _len_dev0; _aux++) { ++ free(dev[_aux].sriov); ++ } ++ free(dev); ++ break; ++ } ++ case 3: ++ { ++ int vf_id = ((-2 * (next_i()%2)) + 1) * next_i(); ++ int _len_dev0 = 1; ++ struct pci_dev * dev = (struct pci_dev *) malloc(_len_dev0*sizeof(struct pci_dev)); ++ for(int _i0 = 0; _i0 < _len_dev0; _i0++) { ++ dev[_i0].devfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ int _len_dev__i0__sriov0 = 1; ++ dev[_i0].sriov = (struct TYPE_2__ *) malloc(_len_dev__i0__sriov0*sizeof(struct TYPE_2__)); ++ for(int _j0 = 0; _j0 < _len_dev__i0__sriov0; _j0++) { ++ dev[_i0].sriov->offset = ((-2 * (next_i()%2)) + 1) * next_i(); ++ dev[_i0].sriov->stride = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ dev[_i0].is_physfn = ((-2 * (next_i()%2)) + 1) * next_i(); ++ } ++ int benchRet = pci_iov_virtfn_devfn(dev,vf_id); ++ printf("%d\n", benchRet); ++ for(int _aux = 0; _aux < _len_dev0; _aux++) { ++ free(dev[_aux].sriov); ++ } ++ free(dev); ++ break; ++ } ++ default: ++ break; ++ } ++ return 0; ++} +\ No newline at end of file +diff --git a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp +index 687f6609f..1ef26229a 100644 +--- a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp ++++ b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp +@@ -43,6 +43,10 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/csr_*.c]] \ + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/rf_*.c]] \ + "" "-fipa-reorder-fields -fdump-ipa-all -flto-partition=one -fwhole-program" + ++# -fipa-struct-reorg=2 ++gcc-dg-runtest $srcdir/$subdir/rf_rewrite_problem_with_split.c \ ++ "" "-fipa-struct-reorg=2 -fdump-ipa-all -flto-partition=one -fwhole-program" ++ + # -fipa-struct-reorg=3 + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dfe*.c]] \ + "" "-fipa-struct-reorg=3 -fdump-ipa-all -flto-partition=one -fwhole-program" +-- +2.25.1 + diff --git a/0322-Bugfix-Create-POINTER_PLUS_EXPR-for-REFERENCE_TYPE.patch b/0322-Bugfix-Create-POINTER_PLUS_EXPR-for-REFERENCE_TYPE.patch new file mode 100644 index 0000000000000000000000000000000000000000..b832c901c8f8a6a96054b4024f5aacebff600c31 --- /dev/null +++ b/0322-Bugfix-Create-POINTER_PLUS_EXPR-for-REFERENCE_TYPE.patch @@ -0,0 +1,26 @@ +From 2c98e0ecaf06bd1ab4b77c85fea6098bfa0b201b Mon Sep 17 00:00:00 2001 +From: Generalov Vasilii WX1339879 +Date: Wed, 4 Dec 2024 14:41:24 +0300 +Subject: [PATCH 2/2] [Bugfix] Create POINTER_PLUS_EXPR for REFERENCE_TYPE + +--- + gcc/ipa-prefetch.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/ipa-prefetch.cc b/gcc/ipa-prefetch.cc +index 685f9c267..220287d66 100644 +--- a/gcc/ipa-prefetch.cc ++++ b/gcc/ipa-prefetch.cc +@@ -2171,7 +2171,8 @@ optimize_function (cgraph_node *n, function *fn) + } + tree var_type = TREE_TYPE (inc_var); + enum tree_code inc_code; +- if (TREE_CODE (var_type) == POINTER_TYPE) ++ enum tree_code var_code = TREE_CODE (var_type); ++ if (var_code == POINTER_TYPE || var_code == REFERENCE_TYPE) + inc_code = POINTER_PLUS_EXPR; + else + inc_code = PLUS_EXPR; +-- +2.25.1 + diff --git a/gcc.spec b/gcc.spec index 35104d29a382f8951451b87c519dc23865d51242..d05220aa7a6ed75caa3da75c363c6b48d468392d 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 56 +%global gcc_release 57 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -426,6 +426,8 @@ Patch317: 0317-Bugfix-set-default-value-when-tune_native-is-NULL.patch Patch318: 0318-add-flag-flto-try.patch Patch319: 0319-CSPGO-fix-bugs-when-using-cspgo.patch Patch320: 0320-if-split-fix-bugs.patch +Patch321: 0321-Struct-reorg-Avoid-doing-struct-split-and-reorder_fi.patch +Patch322: 0322-Bugfix-Create-POINTER_PLUS_EXPR-for-REFERENCE_TYPE.patch # Part 1001-1999 %ifarch sw_64 @@ -1532,6 +1534,8 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P318 -p1 %patch -P319 -p1 %patch -P320 -p1 +%patch -P321 -p1 +%patch -P322 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4154,6 +4158,12 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Mon Dec 09 2024 liyancheng <412998149@qq.com> - 12.3.1-57 +- Type:Bugfix +- ID:NA +- SUG:NA +- DESC: Fix bugs in strcut-reorg and ipa-prefetch. + * Sat Dec 07 2024 huzife <634763349@qq.com> - 12.3.1-56 - Type:Bugfix - ID:NA