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]

Re: [attn port maintainers] fix 23671


> The problem here is that the PA reload patterns were discarding
> the MEM_NOTRAP_P bit on the stack slots, which results in too
> many trapping insns found during fixup_eh_region_note.
> 
> My current thinking is that, with a few exceptions like prologue
> and epilogue generation, it should be considered a BUG if a port
> uses gen_rtx_MEM.  Almost always one should be using something
> from the adjust_address family of routines.

I probably need to do another pass through the PA backend for
gen_rtx_MEM.  In looking at the documentation for MEM_NOTRAP_P
and where it's set, it wasn't obvious to me whether it should
or should not be set on MEMs used for general register saves and
restores.  Normally, these should never trap.  However, they
can trap if stack allocation fails.  What's the correct setting?

> The following patch fixes the reduced test case in 23671, but of
> course I cannot test it properly.  John, I'll leave testing and
> committing this patch to you.

There was a small typo in the original version.  I've committed
the following change.  It was tested on hppa-unknown-linux-gnu and
hppa2.0w-hp-hpux11.11.

Thanks for looking into this,
Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-09-03  Richard Henderson  <rth@redhat.com>
	    John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/23671
	pa.c (emit_move_sequence): Use replace_equiv_address instead of
	gen_rtx_MEM.

Index: config/pa/pa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.c,v
retrieving revision 1.305
diff -u -3 -p -r1.305 pa.c
--- config/pa/pa.c	6 Aug 2005 13:26:13 -0000	1.305
+++ config/pa/pa.c	3 Sep 2005 14:11:23 -0000
@@ -1377,12 +1377,12 @@ emit_move_sequence (rtx *operands, enum 
   if (scratch_reg && reload_in_progress && GET_CODE (operand0) == MEM
       && ((tem = find_replacement (&XEXP (operand0, 0)))
 	  != XEXP (operand0, 0)))
-    operand0 = gen_rtx_MEM (GET_MODE (operand0), tem);
+    operand0 = replace_equiv_address (operand0, tem);
 
   if (scratch_reg && reload_in_progress && GET_CODE (operand1) == MEM
       && ((tem = find_replacement (&XEXP (operand1, 0)))
 	  != XEXP (operand1, 0)))
-    operand1 = gen_rtx_MEM (GET_MODE (operand1), tem);
+    operand1 = replace_equiv_address (operand1, tem);
 
   /* Handle secondary reloads for loads/stores of FP registers from
      REG+D addresses where D does not fit in 5 or 14 bits, including
@@ -1420,7 +1420,7 @@ emit_move_sequence (rtx *operands, enum 
       else
 	emit_move_insn (scratch_reg, XEXP (operand1, 0));
       emit_insn (gen_rtx_SET (VOIDmode, operand0,
-			      gen_rtx_MEM (mode, scratch_reg)));
+			      replace_equiv_address (operand1, scratch_reg)));
       return 1;
     }
   else if (scratch_reg
@@ -1457,7 +1457,8 @@ emit_move_sequence (rtx *operands, enum 
 	}
       else
 	emit_move_insn (scratch_reg, XEXP (operand0, 0));
-      emit_insn (gen_rtx_SET (VOIDmode, gen_rtx_MEM (mode, scratch_reg),
+      emit_insn (gen_rtx_SET (VOIDmode,
+			      replace_equiv_address (operand0, scratch_reg),
 			      operand1));
       return 1;
     }
@@ -1474,7 +1475,7 @@ emit_move_sequence (rtx *operands, enum 
 	   && CONSTANT_P (operand1)
 	   && fp_reg_operand (operand0, mode))
     {
-      rtx xoperands[2];
+      rtx const_mem, xoperands[2];
 
       /* SCRATCH_REG will hold an address and maybe the actual data.  We want
 	 it in WORD_MODE regardless of what mode it was originally given
@@ -1483,13 +1484,14 @@ emit_move_sequence (rtx *operands, enum 
 
       /* Force the constant into memory and put the address of the
 	 memory location into scratch_reg.  */
+      const_mem = force_const_mem (mode, operand1);
       xoperands[0] = scratch_reg;
-      xoperands[1] = XEXP (force_const_mem (mode, operand1), 0);
+      xoperands[1] = XEXP (const_mem, 0);
       emit_move_sequence (xoperands, Pmode, 0);
 
       /* Now load the destination register.  */
       emit_insn (gen_rtx_SET (mode, operand0,
-			      gen_rtx_MEM (mode, scratch_reg)));
+			      replace_equiv_address (const_mem, scratch_reg)));
       return 1;
     }
   /* Handle secondary reloads for SAR.  These occur when trying to load
@@ -1526,8 +1528,8 @@ emit_move_sequence (rtx *operands, enum 
 	     OPERAND0.  */
 	  scratch_reg = force_mode (GET_MODE (operand0), scratch_reg);
 
-	  emit_move_insn (scratch_reg, gen_rtx_MEM (GET_MODE (operand0),
-						    scratch_reg));
+	  emit_move_insn (scratch_reg,
+			  replace_equiv_address (operand1, scratch_reg));
 	}
       else
 	{
@@ -1754,10 +1756,10 @@ emit_move_sequence (rtx *operands, enum 
 		       && (reload_completed || reload_in_progress)
 		       && flag_pic)
 		{
-		  operands[1] = force_const_mem (mode, operand1);
+		  rtx const_mem = force_const_mem (mode, operand1);
 		  operands[1] = legitimize_pic_address (XEXP (operands[1], 0),
 							mode, temp);
-		  operands[1] = gen_rtx_MEM (mode, operands[1]);
+		  operands[1] = replace_equiv_address (const_mem, operands[1]);
 		  emit_move_sequence (operands, mode, temp);
 		}
 	      else


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