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]

Committed, CRIS: Fix PR target/19806


This bug was due to the CRIS variant of output_addr_const
getting out of sync; a mark_decl_referenced call was missing.
The ASM_OUTPUT_LABEL_REF macro (from later the same day the CRIS
port was committed!) made the local variant unnecessary.  I see
there's now both an ASM_OUTPUT_LABEL_REF and ASM_OUTPUT_LABELREF.
Huh.

Sure, I could have just added the mark_decl_referenced call as a
less invasive change, this being stage 3, but that'd just cause
sync problems later.  This is better; it affects no other
target.

This fixes in one fell swoop the following testsuite failures:
FAIL: gcc.c-torture/execute/20001130-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/20010605-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/20030313-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/20050106-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/920721-3.c compilation,  -O0
FAIL: gcc.c-torture/execute/941202-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/941202-1.c compilation,  -O1
FAIL: gcc.c-torture/execute/960116-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/980526-2.c compilation,  -O0
FAIL: gcc.c-torture/execute/990208-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/cvt-1.c compilation,  -O0
FAIL: gcc.c-torture/execute/simd-4.c compilation,  -O0
FAIL: objc/execute/IMP.m compilation,  -O0
FAIL: objc/execute/class-1.m compilation,  -O0
FAIL: objc/execute/class-10.m compilation,  -O0
FAIL: objc/execute/class-11.m compilation,  -O0
FAIL: objc/execute/class-12.m compilation,  -O0
FAIL: objc/execute/class-13.m compilation,  -O0
FAIL: objc/execute/class-14.m compilation,  -O0
FAIL: objc/execute/class-2.m compilation,  -O0
FAIL: objc/execute/class-3.m compilation,  -O0
FAIL: objc/execute/class-4.m compilation,  -O0
FAIL: objc/execute/class-5.m compilation,  -O0
FAIL: objc/execute/class-6.m compilation,  -O0
FAIL: objc/execute/class-7.m compilation,  -O0
FAIL: objc/execute/class-8.m compilation,  -O0
FAIL: objc/execute/class-9.m compilation,  -O0
FAIL: objc/execute/nested-2.m compilation,  -O0
FAIL: objc/execute/object_is_class.m compilation,  -O0
FAIL: objc/execute/object_is_meta_class.m compilation,  -O0

No regressions on cross to cris-elf or cris-linux.

	PR target/19806
	* config/cris/cris.c (in_code): New variable.
	(cris_output_addr_const): Now a static function, a wrapper for
	output_addr_const.
	(cris_asm_output_symbol_ref): New function, broken out SYMBOL_REF
	case from old cris_output_addr_const.
	(cris_asm_output_label_ref): Similar for LABEL_REF.
	(cris_output_addr_const_extra): Similar for UNSPEC.
	* config/cris/cris.h (OUTPUT_ADDR_CONST_EXTRA)
	(ASM_OUTPUT_SYMBOL_REF, ASM_OUTPUT_LABEL_REF): Define.
	* config/cris/cris-protos.h (cris_output_addr_const): Remove
	declaration.
	(cris_asm_output_symbol_ref, cris_output_addr_const_extra)
	(cris_asm_output_label_ref): Declare.



Index: cris/cris-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris-protos.h,v
retrieving revision 1.13
diff -c -p -r1.13 cris-protos.h
*** cris/cris-protos.h	15 Sep 2004 17:03:02 -0000	1.13
--- cris/cris-protos.h	8 Feb 2005 15:35:45 -0000
*************** extern int cris_legitimate_pic_operand (
*** 42,50 ****
  extern int cris_gotless_symbol (rtx);
  extern int cris_got_symbol (rtx);
  extern int cris_symbol (rtx);
! extern void cris_output_addr_const (FILE *, rtx);
  extern int cris_cfun_uses_pic_table (void);
  #endif /* RTX_CODE */
  extern void cris_target_asm_named_section (const char *, unsigned int, tree);
  
  extern int cris_return_address_on_stack (void);
--- 42,52 ----
  extern int cris_gotless_symbol (rtx);
  extern int cris_got_symbol (rtx);
  extern int cris_symbol (rtx);
! extern void cris_asm_output_symbol_ref (FILE *, rtx);
! extern bool cris_output_addr_const_extra (FILE *, rtx);
  extern int cris_cfun_uses_pic_table (void);
  #endif /* RTX_CODE */
+ extern void cris_asm_output_label_ref (FILE *, char *);
  extern void cris_target_asm_named_section (const char *, unsigned int, tree);
  
  extern int cris_return_address_on_stack (void);
Index: cris/cris.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.c,v
retrieving revision 1.62
diff -c -p -r1.62 cris.c
*** cris/cris.c	30 Dec 2004 03:07:44 -0000	1.62
--- cris/cris.c	8 Feb 2005 15:35:45 -0000
*************** static char cris_output_insn_is_bound = 
*** 83,88 ****
--- 83,92 ----
     just the "sym:GOTOFF" part.  */
  static int cris_pic_sympart_only = 0;
  
+ /* In code for output macros, this is how we know whether e.g. constant
+    goes in code or in a static initializer.  */
+ static int in_code = 0;
+ 
  /* Fix for reg_overlap_mentioned_p.  */
  static int cris_reg_overlap_mentioned_p (rtx, rtx);
  
*************** static void cris_print_base (rtx, FILE *
*** 90,95 ****
--- 94,101 ----
  
  static void cris_print_index (rtx, FILE *);
  
+ static void cris_output_addr_const (FILE *, rtx);
+ 
  static struct machine_function * cris_init_machine_status (void);
  
  static rtx cris_struct_value_rtx (tree, int);
*************** cris_split_movdx (rtx *operands)
*** 2972,3149 ****
    return val;
  }
  
! /* This is in essence a copy of output_addr_const altered to output
!    symbolic operands as PIC.
! 
!    FIXME: Add hooks similar to ASM_OUTPUT_SYMBOL_REF to get this effect in
!    the "real" output_addr_const.  All we need is one for LABEL_REF (and
!    one for CODE_LABEL?).  */
  
! void
  cris_output_addr_const (FILE *file, rtx x)
  {
!   int is_plt = 0;
! 
! restart:
!   switch (GET_CODE (x))
!     {
!     case UNSPEC:
!       ASSERT_PLT_UNSPEC (x);
!       x = XVECEXP (x, 0, 0);
!       is_plt = 1;
! 
!       /* Fall through.  */
!     case SYMBOL_REF:
!       if (flag_pic)
! 	{
! 	  const char *origstr = XSTR (x, 0);
! 	  const char *str;
  
! 	  str = (* targetm.strip_name_encoding) (origstr);
  
! 	  if (is_plt)
! 	    {
! 	      if (cris_pic_sympart_only)
! 		{
! 		  assemble_name (file, str);
! 		  fprintf (file, ":PLTG");
! 		}
! 	      else
! 		{
! 		  if (TARGET_AVOID_GOTPLT)
! 		    /* We shouldn't get here.  */
! 		    abort ();
  
! 		  fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 		  assemble_name (file, XSTR (x, 0));
  
! 		  if (flag_pic == 1)
! 		    fprintf (file, ":GOTPLT16]");
! 		  else
! 		    fprintf (file, ":GOTPLT]");
! 		}
! 	    }
! 	  else if (cris_gotless_symbol (x))
! 	    {
! 	      if (! cris_pic_sympart_only)
! 		fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	      assemble_name (file, str);
! 	      fprintf (file, ":GOTOFF");
! 	    }
! 	  else if (cris_got_symbol (x))
! 	    {
! 	      if (cris_pic_sympart_only)
! 		abort ();
! 	      fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	      assemble_name (file, XSTR (x, 0));
  
! 	      if (flag_pic == 1)
! 		fprintf (file, ":GOT16]");
! 	      else
! 		fprintf (file, ":GOT]");
! 	    }
  	  else
! 	    LOSE_AND_RETURN ("unexpected PIC symbol", x);
! 
! 	  /* Sanity check.  */
! 	  if (! current_function_uses_pic_offset_table)
! 	    output_operand_lossage ("PIC register isn't set up");
  	}
        else
! 	assemble_name (file, XSTR (x, 0));
!       break;
  
!     case LABEL_REF:
!       /* If we get one of those here, it should be dressed as PIC.  Branch
! 	 labels are normally output with the 'l' specifier, which means it
! 	 will go directly to output_asm_label and not end up here.  */
!       if (GET_CODE (XEXP (x, 0)) != CODE_LABEL
! 	  && (GET_CODE (XEXP (x, 0)) != NOTE
! 	      || NOTE_LINE_NUMBER (XEXP (x, 0)) != NOTE_INSN_DELETED_LABEL))
! 	fatal_insn ("unexpected address expression", x);
  
!       if (flag_pic)
! 	{
! 	  if (cris_gotless_symbol (x))
! 	    {
! 	      if (! cris_pic_sympart_only)
! 		fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	      cris_output_addr_const (file, XEXP (x, 0));
  
! 	      fprintf (file, ":GOTOFF");
! 	    }
! 	  else
! 	    /* Labels are never marked as global symbols.  */
! 	    fatal_insn ("unexpected PIC symbol", x);
  
! 	  /* Sanity check.  */
! 	  if (! current_function_uses_pic_offset_table)
! 	    internal_error ("emitting PIC operand, but PIC register isn't set up");
! 	  break;
! 	}
  
!       output_addr_const (file, x);
!       break;
  
!     case NOTE:
!       if (NOTE_LINE_NUMBER (x) != NOTE_INSN_DELETED_LABEL)
! 	fatal_insn ("unexpected NOTE as addr_const:", x);
!     case CODE_LABEL:
!     case CONST_INT:
!     case CONST_DOUBLE:
!     case ZERO_EXTEND:
!     case SIGN_EXTEND:
!       output_addr_const (file, x);
!       break;
  
!     case CONST:
!       /* This used to output parentheses around the expression,
! 	 but that does not work on the 386 (either ATT or BSD assembler).  */
!       cris_output_addr_const (file, XEXP (x, 0));
!       break;
  
!     case PLUS:
!       /* Some assemblers need integer constants to appear last (e.g. masm).  */
!       if (GET_CODE (XEXP (x, 0)) == CONST_INT)
  	{
! 	  cris_output_addr_const (file, XEXP (x, 1));
! 	  if (INTVAL (XEXP (x, 0)) >= 0)
! 	    fprintf (file, "+");
! 	  output_addr_const (file, XEXP (x, 0));
  	}
        else
  	{
! 	  cris_output_addr_const (file, XEXP (x, 0));
! 	  if (GET_CODE (XEXP (x, 1)) != CONST_INT
! 	      || INTVAL (XEXP (x, 1)) >= 0)
! 	    fprintf (file, "+");
! 	  cris_output_addr_const (file, XEXP (x, 1));
! 	}
!       break;
  
!     case MINUS:
!       /* Avoid outputting things like x-x or x+5-x,
! 	 since some assemblers can't handle that.  */
!       x = simplify_subtraction (x);
!       if (GET_CODE (x) != MINUS)
! 	goto restart;
! 
!       cris_output_addr_const (file, XEXP (x, 0));
!       fprintf (file, "-");
!       if ((GET_CODE (XEXP (x, 1)) == CONST_INT
! 	   && INTVAL (XEXP (x, 1)) < 0)
! 	  || GET_CODE (XEXP (x, 1)) != CONST_INT)
! 	{
! 	  fprintf (file, "%s", targetm.asm_out.open_paren);
! 	  cris_output_addr_const (file, XEXP (x, 1));
! 	  fprintf (file, "%s", targetm.asm_out.close_paren);
  	}
!       else
! 	output_addr_const (file, XEXP (x, 1));
!       break;
  
      default:
!       LOSE_AND_RETURN ("unexpected address expression", x);
      }
  }
  
--- 2978,3097 ----
    return val;
  }
  
! /* Use from within code, from e.g. PRINT_OPERAND and
!    PRINT_OPERAND_ADDRESS.  Macros used in output_addr_const need to emit
!    different things depending on whether code operand or constant is
!    emitted.  */
  
! static void
  cris_output_addr_const (FILE *file, rtx x)
  {
!   in_code++;
!   output_addr_const (file, x);
!   in_code--;
! }
  
! /* Worker function for ASM_OUTPUT_SYMBOL_REF.  */
  
! void
! cris_asm_output_symbol_ref (FILE *file, rtx x)
! {
!   if (flag_pic && in_code > 0)
!     {
!       const char *origstr = XSTR (x, 0);
!       const char *str;
  
!       str = (* targetm.strip_name_encoding) (origstr);
  
!       if (cris_gotless_symbol (x))
! 	{
! 	  if (! cris_pic_sympart_only)
! 	    fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	  assemble_name (file, str);
! 	  fprintf (file, ":GOTOFF");
! 	}
!       else if (cris_got_symbol (x))
! 	{
! 	  if (cris_pic_sympart_only)
! 	    abort ();
! 	  fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	  assemble_name (file, XSTR (x, 0));
  
! 	  if (flag_pic == 1)
! 	    fprintf (file, ":GOT16]");
  	  else
! 	    fprintf (file, ":GOT]");
  	}
        else
! 	LOSE_AND_RETURN ("unexpected PIC symbol", x);
  
!       /* Sanity check.  */
!       if (! current_function_uses_pic_offset_table)
! 	output_operand_lossage ("PIC register isn't set up");
!     }
!   else
!     assemble_name (file, XSTR (x, 0));
! }
  
! /* Worker function for ASM_OUTPUT_LABEL_REF.  */
  
! void
! cris_asm_output_label_ref (FILE *file, char *buf)
! {
!   if (flag_pic && in_code > 0)
!     {
!       if (! cris_pic_sympart_only)
! 	fprintf (file, "$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
!       assemble_name (file, buf);
  
!       fprintf (file, ":GOTOFF");
  
!       /* Sanity check.  */
!       if (! current_function_uses_pic_offset_table)
! 	internal_error ("emitting PIC operand, but PIC register isn't set up");
!     }
!   else
!     assemble_name (file, buf);
! }
  
! /* Worker function for OUTPUT_ADDR_CONST_EXTRA.  */
  
! bool
! cris_output_addr_const_extra (FILE *file, rtx x)
! {
!   switch (GET_CODE (x))
!     {
!       const char *origstr;
!       const char *str;
  
!     case UNSPEC:
!       ASSERT_PLT_UNSPEC (x);
!       x = XVECEXP (x, 0, 0);
!       origstr = XSTR (x, 0);
!       str = (* targetm.strip_name_encoding) (origstr);
!       if (cris_pic_sympart_only)
  	{
! 	  assemble_name (file, str);
! 	  fprintf (file, ":PLTG");
  	}
        else
  	{
! 	  if (TARGET_AVOID_GOTPLT)
! 	    /* We shouldn't get here.  */
! 	    abort ();
  
! 	  fprintf (file, "[$%s+", reg_names [PIC_OFFSET_TABLE_REGNUM]);
! 	  assemble_name (file, XSTR (x, 0));
! 
! 	  if (flag_pic == 1)
! 	    fprintf (file, ":GOTPLT16]");
! 	  else
! 	    fprintf (file, ":GOTPLT]");
  	}
!       return true;
  
      default:
!       return false;
      }
  }
  
Index: cris/cris.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.h,v
retrieving revision 1.83
diff -c -p -r1.83 cris.h
*** cris/cris.h	27 Jan 2005 18:22:28 -0000	1.83
--- cris/cris.h	8 Feb 2005 15:35:45 -0000
*************** struct cum_args {int regs;};
*** 1352,1357 ****
--- 1352,1360 ----
  
  /* Node: Data Output */
  
+ #define OUTPUT_ADDR_CONST_EXTRA(STREAM, X, FAIL) \
+   do { if (!cris_output_addr_const_extra (STREAM, X)) goto FAIL; } while (0)
+ 
  #define IS_ASM_LOGICAL_LINE_SEPARATOR(C) (C) == '@'
  
  /* Node: Uninitialized Data */
*************** struct cum_args {int regs;};
*** 1422,1427 ****
--- 1425,1436 ----
  
  #define SUPPORTS_WEAK 1
  
+ #define ASM_OUTPUT_SYMBOL_REF(STREAM, SYM) \
+  cris_asm_output_symbol_ref (STREAM, SYM)
+ 
+ #define ASM_OUTPUT_LABEL_REF(STREAM, BUF) \
+  cris_asm_output_label_ref (STREAM, BUF)
+ 
  /* Remove any previous definition (elfos.h).  */
  #undef ASM_GENERATE_INTERNAL_LABEL
  #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)	\

brgds, H-P


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