public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1319] loongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]
@ 2022-06-28 11:03 Xi Ruoyao
0 siblings, 0 replies; only message in thread
From: Xi Ruoyao @ 2022-06-28 11:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:020b7d98589bbc928b5a66b1ed56b42af8791355
commit r13-1319-g020b7d98589bbc928b5a66b1ed56b42af8791355
Author: Xi Ruoyao <xry111@xry111.site>
Date: Tue Jun 28 16:00:14 2022 +0800
loongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]
The epilogue may clobber LARCH_PROLOGUE_TEMP ($r13/$t1), so it cannot be
used for sibcalls.
gcc/ChangeLog:
PR target/106096
* config/loongarch/loongarch.h (REG_CLASS_CONTENTS): Exclude
$r13 from SIBCALL_REGS.
* config/loongarch/loongarch.cc (loongarch_regno_to_class):
Change $r13 to JIRL_REGS.
gcc/testsuite/ChangeLog:
PR target/106096
* g++.target/loongarch/loongarch.exp: New test support file.
* g++.target/loongarch/pr106096.C: New test.
Diff:
---
gcc/config/loongarch/loongarch.cc | 2 +-
gcc/config/loongarch/loongarch.h | 2 +-
gcc/testsuite/g++.target/loongarch/loongarch.exp | 34 +++++++++++
gcc/testsuite/g++.target/loongarch/pr106096.C | 75 ++++++++++++++++++++++++
4 files changed, 111 insertions(+), 2 deletions(-)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 80046b64006..c8502b0b0f3 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -189,7 +189,7 @@ const enum reg_class loongarch_regno_to_class[FIRST_PSEUDO_REGISTER] = {
GR_REGS, GR_REGS, GR_REGS, GR_REGS,
JIRL_REGS, JIRL_REGS, JIRL_REGS, JIRL_REGS,
JIRL_REGS, JIRL_REGS, JIRL_REGS, JIRL_REGS,
- SIBCALL_REGS, SIBCALL_REGS, SIBCALL_REGS, SIBCALL_REGS,
+ SIBCALL_REGS, JIRL_REGS, SIBCALL_REGS, SIBCALL_REGS,
SIBCALL_REGS, SIBCALL_REGS, SIBCALL_REGS, SIBCALL_REGS,
SIBCALL_REGS, GR_REGS, GR_REGS, JIRL_REGS,
JIRL_REGS, JIRL_REGS, JIRL_REGS, JIRL_REGS,
diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h
index 4d107a42209..f9de9a6e4fb 100644
--- a/gcc/config/loongarch/loongarch.h
+++ b/gcc/config/loongarch/loongarch.h
@@ -511,7 +511,7 @@ enum reg_class
#define REG_CLASS_CONTENTS \
{ \
{ 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
- { 0x001ff000, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \
+ { 0x001fd000, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \
{ 0xff9ffff0, 0x00000000, 0x00000000 }, /* JIRL_REGS */ \
{ 0xfffffffc, 0x00000000, 0x00000000 }, /* CSR_REGS */ \
{ 0xffffffff, 0x00000000, 0x00000000 }, /* GR_REGS */ \
diff --git a/gcc/testsuite/g++.target/loongarch/loongarch.exp b/gcc/testsuite/g++.target/loongarch/loongarch.exp
new file mode 100644
index 00000000000..4fd1194a552
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/loongarch.exp
@@ -0,0 +1,34 @@
+# Copyright (C) 2019-2022 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a LoongArch target.
+if ![istarget loongarch*-*-*] then {
+ return
+}
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/g++.target/loongarch/pr106096.C b/gcc/testsuite/g++.target/loongarch/pr106096.C
new file mode 100644
index 00000000000..5edbda220f7
--- /dev/null
+++ b/gcc/testsuite/g++.target/loongarch/pr106096.C
@@ -0,0 +1,75 @@
+/* PR target/106096
+ Reduced from gimple-range-path.cc. It was miscompiled with -O2 and
+ caused ICE (segfault) building stage 2 libgcc. */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+enum E
+{
+ TS_TYPED
+} a;
+int b, c;
+char d, e;
+
+__attribute__ ((cold, noipa, noinline)) void
+cold (int *, E, char *, int, char *)
+{
+ __builtin_trap ();
+}
+
+int *
+contains_struct_check (E x)
+{
+ if (a)
+ cold (&b, x, &d, c, &e);
+ return &b;
+}
+
+struct vrange
+{
+ virtual void set_varying (int *);
+};
+
+struct int_range : vrange
+{
+ int *m_ranges[510];
+};
+
+__attribute__ ((noipa, noinline)) void
+vrange::set_varying (int *)
+{
+}
+
+struct Value_Range
+{
+ Value_Range (int *);
+ int_range m_irange;
+};
+
+__attribute__ ((noipa, noinline)) Value_Range::Value_Range (int *) {}
+
+struct path_range_query
+{
+ void ssa_range_in_phi (vrange &);
+ bool m_resolve;
+};
+
+__attribute__ ((noipa, noinline)) void
+path_range_query::ssa_range_in_phi (vrange &r)
+{
+ if (m_resolve)
+ {
+ Value_Range (contains_struct_check (TS_TYPED));
+ return;
+ }
+ r.set_varying (contains_struct_check (TS_TYPED));
+}
+
+int
+main ()
+{
+ path_range_query prq{ 0 };
+ vrange vr;
+ prq.ssa_range_in_phi (vr);
+ return 0;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-28 11:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 11:03 [gcc r13-1319] loongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096] Xi Ruoyao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).