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.
This commit is contained in:
Xi Ruoyao 2022-06-28 16:00:14 +08:00
parent 88417d77fe
commit 020b7d9858
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3
4 changed files with 111 additions and 2 deletions

View File

@ -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,

View File

@ -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 */ \

View File

@ -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

View File

@ -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;
}