From c66875ae0c21a4d47c2f8ff05bfaa7cf7dba6187 Mon Sep 17 00:00:00 2001 From: liyancheng <412998149@qq.com> Date: Mon, 11 Apr 2022 11:05:27 +0800 Subject: [PATCH] [Loongarch] Backport: lra: clear lra_insn_recog_data after simplifying a mem subreg --- ...sn_recog_data-after-simplifying-a-me.patch | 57 +++++++++++++++++++ gcc.spec | 10 +++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 0036-lra-clear-lra_insn_recog_data-after-simplifying-a-me.patch diff --git a/0036-lra-clear-lra_insn_recog_data-after-simplifying-a-me.patch b/0036-lra-clear-lra_insn_recog_data-after-simplifying-a-me.patch new file mode 100644 index 0000000..a30761b --- /dev/null +++ b/0036-lra-clear-lra_insn_recog_data-after-simplifying-a-me.patch @@ -0,0 +1,57 @@ +From 6dc82826ba61b25855e5a79f4479d009395a7299 Mon Sep 17 00:00:00 2001 +From: Ilya Leoshkevich +Date: Wed, 13 Jan 2021 13:59:10 +0100 +Subject: [PATCH 0001/6575] lra: clear lra_insn_recog_data after simplifying a + mem subreg + +Suppose we have: + + (insn (set (reg:FPRX2 70) (subreg:FPRX2 (reg/v:TF 63) 0))) + +where operand_loc[0] points to r70 and operand_loc[1] points to r63. +If r63 is spilled, remove_pseudos() will change this insn to: + + (insn (set (reg:FPRX2 70) + (subreg:FPRX2 (mem/c:TF (plus:DI (reg:DI %fp) + (const_int 144)))))) + +This is fine so far: rtx pointed to by operand_loc[1] has been changed +from (reg) to (mem), but its slot is still under (subreg). However, +alter_subreg() will simplify this insn to: + + (insn (set (reg:FPRX2 70) + (mem/c:FPRX2 (plus:DI (reg:DI %fp) (const_int 144))))) + +The (subreg) is gone, and therefore operand_loc[1] is no longer valid. +This will prevent process_insn_for_elimination() from updating the spill +slot offset, causing miscompilation: different instructions will refer +to the same spill slot using different offsets. + +Fix by clearing all the cached data, and not just used_insn_alternative. + +gcc/ChangeLog: + +2021-01-13 Ilya Leoshkevich + + * lra-spills.c (remove_pseudos): Call lra_update_insn_recog_data() + after calling alter_subreg() on a (mem). +--- + gcc/lra-spills.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/lra-spills.c b/gcc/lra-spills.c +index 26f56b2df02..01bd82574e7 100644 +--- a/gcc/lra-spills.c ++++ b/gcc/lra-spills.c +@@ -431,7 +431,7 @@ remove_pseudos (rtx *loc, rtx_insn *insn) + alter_subreg (loc, false); + if (GET_CODE (*loc) == MEM) + { +- lra_get_insn_recog_data (insn)->used_insn_alternative = -1; ++ lra_update_insn_recog_data (insn); + if (lra_dump_file != NULL) + fprintf (lra_dump_file, + "Memory subreg was simplified in insn #%u\n", +-- +2.27.0 + diff --git a/gcc.spec b/gcc.spec index 97c3e99..a1a124e 100644 --- a/gcc.spec +++ b/gcc.spec @@ -61,7 +61,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: 12 +Release: 13 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD URL: https://gcc.gnu.org @@ -151,6 +151,7 @@ Patch32: 0032-Autoprefetch-Prune-invaild-loops-containing-edges-wh.patch Patch33: 0033-Add-Loongarch-backend-support.patch Patch34: 0034-Loongarch-add-clobber-for-csr-builtin.patch Patch35: 0035-Fixup-missing-file-error.patch +Patch36: 0036-lra-clear-lra_insn_recog_data-after-simplifying-a-me.patch %global gcc_target_platform %{_arch}-linux-gnu @@ -627,6 +628,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch33 -p1 %patch34 -p1 %patch35 -p1 +%patch36 -p1 %build @@ -2596,6 +2598,12 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Mon Apr 11 2022 liyancheng <412998149@qq.com> - 10.3.1-13 +- Type:requirements +- ID:NA +- SUG:NA +- DESC:Backport:clear lra_insn_recog_data after simplifying a mem subreg + * Mon Apr 06 2022 lixing - 10.3.1-12 - Type:requirements - ID:NA -- Gitee