This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: scheduling vs variable arrays


This adds a memory clobber following a block containing variable arrays,
to prevent the scheduler from moving references to such arrays below
the stack pop. (As suggested by Richard Henderson, thanks.)
Bootstrapping on Darwin.

2002-08-08 Dale Johannesen <dalej@apple.com>

* explow.c (emit_stack_restore): Emit a memory clobber
preceding the stack pop, to prevent the scheduler from
moving refs to variable arrays below this pop.
* reload1.c (reload): Preserve this clobber for sched2.
* doc/rtl.texi: Document clobber (mem:BLK (scratch)).

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.351
diff -u -d -b -w -c -3 -p -r1.351 reload1.c
cvs server: conflicting specifications of output style
*** reload1.c 30 Jul 2002 16:42:05 -0000 1.351
--- reload1.c 8 Aug 2002 22:57:46 -0000
*************** reload (first, global)
*** 1181,1186 ****
--- 1181,1187 ----
/* Make a pass over all the insns and delete all USEs which we inserted
only to tag a REG_EQUAL note on them. Remove all REG_DEAD and REG_UNUSED
notes. Delete all CLOBBER insns that don't refer to the return value
+ or to memory (memory CLOBBERs must be kept around for scheduler dependencies)
and simplify (subreg (reg)) operands. Also remove all REG_RETVAL and
REG_LIBCALL notes since they are no longer useful or accurate. Strip
and regenerate REG_INC notes that may have been moved around. */
*************** reload (first, global)
*** 1200,1205 ****
--- 1201,1207 ----
&& (GET_MODE (insn) == QImode
|| find_reg_note (insn, REG_EQUAL, NULL_RTX)))
|| (GET_CODE (PATTERN (insn)) == CLOBBER
+ && GET_CODE (XEXP (PATTERN (insn), 0)) != MEM
&& (GET_CODE (XEXP (PATTERN (insn), 0)) != REG
|| ! REG_FUNCTION_VALUE_P (XEXP (PATTERN (insn), 0))))
)
{
Index: explow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/explow.c,v
retrieving revision 1.98
diff -u -d -b -w -c -3 -p -r1.98 explow.c
cvs server: conflicting specifications of output style
*** explow.c 2 Aug 2002 11:57:16 -0000 1.98
--- explow.c 8 Aug 2002 22:57:46 -0000
*************** emit_stack_restore (save_level, sa, afte
*** 1059,1065 ****
--- 1059,1073 ----
}

if (sa != 0)
+ {
sa = validize_mem (sa);
+ /* This clobber prevents the scheduler from moving
+ references to variable arrays below the code
+ that deletes (pops) the arrays. */
+ emit_insn (gen_rtx_CLOBBER (VOIDmode,
+ gen_rtx_MEM (BLKmode,
+ gen_rtx_SCRATCH (VOIDmode))));
+ }

if (after)
{
Index: doc/rtl.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/rtl.texi,v
retrieving revision 1.40
diff -u -d -b -w -c -3 -p -r1.40 rtl.texi
cvs server: conflicting specifications of output style
*** doc/rtl.texi 19 Jul 2002 23:11:19 -0000 1.40
--- doc/rtl.texi 8 Aug 2002 22:57:46 -0000
*************** trouble to describe the values that are
*** 2294,2302 ****
inform the compiler that the registers will be altered, lest it
attempt to keep data in them across the string instruction.

! If @var{x} is @code{(mem:BLK (const_int 0))}, it means that all memory
! locations must be presumed clobbered. If @var{x} is a @code{parallel},
! it has the same meaning as a @code{parallel} in a @code{set} expression.

Note that the machine description classifies certain hard registers as
``call-clobbered''. All function call instructions are assumed by
--- 2294,2303 ----
inform the compiler that the registers will be altered, lest it
attempt to keep data in them across the string instruction.

! If @var{x} is @code{(mem:BLK (const_int 0))} or
! @code{(mem:BLK (scratch))}, it means that all memory locations must
! be presumed clobbered. If @var{x} is a @code{parallel}, it has the
! same meaning as a @code{parallel} in a @code{set} expression.

Note that the machine description classifies certain hard registers as
``call-clobbered''. All function call instructions are assumed by


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]