[PATCH] Check regs_invalidated_in_call in reg_set_p
Roger Sayle
roger@eyesopen.com
Mon Jul 19 13:35:00 GMT 2004
This patch is inspired by Zack's analysis of the comment in reg_set_p
where that function handles call clobbered registers that reads:
> We'd like to test call_used_regs here, but rtlanal.c can't
> reference that variable due to its use in genattrtab. So
> we'll just be more conservative.
As Zack pointed out rtlanal.o isn't linked into genattrtab or any
of the gen* executables, so we can use call_used_regs. However
investigating further I discovered that the preferred idiom for
this test is actually to use the regs_invalidated_by_call hard
reg-set. This has the benefit over call_used_regs that it doesn't
include "fixed" registers, so that the frame pointer, for example,
isn't unconditionally considered clobbered by a function call.
The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.
Ok for mainline?
2004-07-18 Roger Sayle <roger@eyesopen.com>
* rtlanal.c (reg_set_p): Add check for regs_invalidated_by_call.
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.196
diff -c -3 -p -r1.196 rtlanal.c
*** rtlanal.c 14 Jul 2004 07:30:17 -0000 1.196
--- rtlanal.c 18 Jul 2004 19:47:56 -0000
*************** reg_set_p (rtx reg, rtx insn)
*** 941,954 ****
if (INSN_P (insn)
&& (FIND_REG_INC_NOTE (insn, reg)
|| (CALL_P (insn)
- /* We'd like to test call_used_regs here, but rtlanal.c can't
- reference that variable due to its use in genattrtab. So
- we'll just be more conservative.
-
- ??? Unless we could ensure that the CALL_INSN_FUNCTION_USAGE
- information holds all clobbered registers. */
&& ((REG_P (reg)
! && REGNO (reg) < FIRST_PSEUDO_REGISTER)
|| MEM_P (reg)
|| find_reg_fusage (insn, CLOBBER, reg)))))
return 1;
--- 941,950 ----
if (INSN_P (insn)
&& (FIND_REG_INC_NOTE (insn, reg)
|| (CALL_P (insn)
&& ((REG_P (reg)
! && REGNO (reg) < FIRST_PSEUDO_REGISTER
! && TEST_HARD_REG_BIT (regs_invalidated_by_call,
! REGNO (reg)))
|| MEM_P (reg)
|| find_reg_fusage (insn, CLOBBER, reg)))))
return 1;
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833
More information about the Gcc-patches
mailing list