PATCH: Fix location for pic register save on trunk

John David Anglin dave@hiauly1.hia.nrc.ca
Mon Jun 18 11:03:00 GMT 2001


This patch changes the location used for the pic register save to be the
same as that used in the 3.0 release.  With this patch installed, the g++
and v3 testsuite results are essentially identical to those of the release.

Without the patch, there are a large number of g++ and v3 failures.  I posted
a summary here: < http://gcc.gnu.org/ml/gcc-testresults/2001-06/msg00368.html >.
The results of a bootstrap check with the patch are posted here:
< http://gcc.gnu.org/ml/gcc-testresults/2001-06/msg00423.html >.  As can be
seen, there is a major improvement.

The v3 FAILs with `-static' are a different problem.  They result from
g++ not handling the `-Xlinger' option.  A patch for that was posted here:
< http://gcc.gnu.org/ml/gcc-patches/2001-06/msg00378.html >.  This patch
needs a review.

I suspected that the pic register save was the problem for the g++ FAILs
and this was confimed when I examined the FAIL of cxa_vec.C in detail.
The pic register save insn was deleted from the function __cxa_vec_new2
in libstdc++-v3/libsupc++/vec.cc.  Looking at the rtl, I saw that the
problem was our old friend EH butting into line ahead the pic save insn.
There is a call in the EH initialization and this results in the pic
save insn being deleted by flow.

Here is the arrangement of insns at the beginning of a __cxa_vec_new2:

(note 1 0 6 ("../../../../libstdc++-v3/libsupc++/vec.cc") 84)

[parm insns]

(note 19 36 23 NOTE_INSN_FUNCTION_BEG)

[function body]

EH buts into line in pass 2.  The function sjlj_emit_function_enter emits
insns to construct the function context after the NOTE_INSN_FUNCTION_BEG note.
The current code in the trunk puts the pic register save insn after this note.

The only place to put the pic save insn is after the parm insns just before
the NOTE_INSN_FUNCTION_BEG note.  That is the approach in this patch.
The only other possibility would be to allow the backend to reserve space
after the note and change except.c to insert the EH context stuff after
the last insn used by the backend at the beginning of the function body.  

I don't believe extra passes are needed to emit the pic save in the main body
of the function.  This has been discussed recently.  For example,
< http://gcc.gnu.org/ml/gcc-patches/2001-06/msg01221.html >.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-06-16  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* pa.c (hppa_init_pic_save): Put pic save insn after last parm insn
	or after first insn if there are no parm insns.

--- pa.c.orig	Fri Jun 15 22:07:11 2001
+++ pa.c	Fri Jun 15 22:14:03 2001
@@ -3371,12 +3371,12 @@
   RTX_UNCHANGING_P (PIC_OFFSET_TABLE_SAVE_RTX) = 1;
   insn = gen_rtx_SET (VOIDmode, PIC_OFFSET_TABLE_SAVE_RTX, picreg);
 
-  /* Emit the insn at the beginning of the function after the prologue.  */
-  if (tail_recursion_reentry)
-    emit_insn_before (insn, tail_recursion_reentry);
-  else
-    /* We must have been called via PROFILE_HOOK.  */
-    emit_insn (insn);
+  /* Emit the insn at the beginning of the function after the prologue.
+     The save must come before the NOTE_INSN_FUNCTION_BEG note.  EH
+     inserts its setup insns just after this note.  */
+  push_topmost_sequence ();
+  emit_insn_after (insn, last_parm_insn ? last_parm_insn : get_insns ());
+  pop_topmost_sequence ();
 }
 
 void



More information about the Gcc-patches mailing list