From b14ee6c9ce76804143ab60dacf31f2fc8c6646b9 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sun, 17 Apr 2011 17:29:52 +0000 Subject: [PATCH] mips.c (mips_cfun_call_saved_reg_p): Handle global registers. gcc/ * config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global registers. gcc/testsuite/ * gcc.target/mips/reg-var-1.c: New test. From-SVN: r172616 --- gcc/ChangeLog | 5 +++++ gcc/config/mips/mips.c | 5 +++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/mips/reg-var-1.c | 16 ++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/mips/reg-var-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b6d583bc195..4212388a4b4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-04-17 Richard Sandiford + + * config/mips/mips.c (mips_cfun_call_saved_reg_p): Handle global + registers. + 2011-04-17 Jan Hubicka * cgrpah.h (struct cgraph_node): Remove finalized_by_frontend. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index f65964b63e8..e075c4f2648 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -9097,6 +9097,11 @@ mips_interrupt_extra_call_saved_reg_p (unsigned int regno) static bool mips_cfun_call_saved_reg_p (unsigned int regno) { + /* If the user makes an ordinarily-call-saved register global, + that register is no longer call-saved. */ + if (global_regs[regno]) + return false; + /* Interrupt handlers need to save extra registers. */ if (cfun->machine->interrupt_handler_p && mips_interrupt_extra_call_saved_reg_p (regno)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cf1dc6b00a..fa74ad298ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-17 Richard Sandiford + + * gcc.target/mips/reg-var-1.c: New test. + 2011-04-17 Jan Hubicka * gcc.dg/winline-5.c: Update testcase. diff --git a/gcc/testsuite/gcc.target/mips/reg-var-1.c b/gcc/testsuite/gcc.target/mips/reg-var-1.c new file mode 100644 index 00000000000..d8b8118103a --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/reg-var-1.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ +register int g asm ("$18"); + +void __attribute__((noinline)) +test (void) +{ + g = g + 1; +} + +int +main (void) +{ + g = 2; + test (); + return g != 3; +} -- 2.30.2