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][rs6000] tighten checks before calling get_pool_constant


Hi,

Without libcall notes we have failures on rs6000 that occur because
rs6000 accepts addresses for constant pool entries that the middle end
does not accept.

The failure occurs in rs6000_legitimize_reload_address which in the
patched compiler (no libcall notes) is at line 4192 and looks like:

 if (TARGET_TOC
    && constant_pool_expr_p (x)
    && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
  {
    x = create_TOC_reference (x);
    *win = 1;
    return x;
  }

The problem is that that rs6000.c:constant_pool_expr_p() is much more
general than varasm.c:get_constant_pool(). Consider:

(gdb) p debug_rtx (addr)
(const:DI (plus:DI (symbol_ref/u:DI ("*.LC169") [flags 0x2])
      (const_int 8 [0x8])))
$1 = void

constant_pool_expr_p() returns true this PLUS expressions, but
get_pool_constant only works on SYMBOL_REFs.  GCC ICEs with an RTL
accessor checking failure in SYMBOL_REF_CONSTANT.

The attached patch adds checks in rs6000.c in all places where
get_pool_constant() is called after constant_pool_expr_p().

Bootstrapped and tested on powerpc64-linux (-m32/-m64).  OK?

Gr.
Steven
	* config/rs6000/rs6000.c (rs6000_legitimize_address,
	rs6000_legitimize_reload_address, rs6000_emit_move): Make sure an
	rtx is a SYMBOL_REF before calling get_pool_constant.

Index: rs6000.c
===================================================================
*** rs6000.c	(revision 136055)
--- rs6000.c	(working copy)
*************** rs6000_legitimize_address (rtx x, rtx ol
*** 3746,3751 ****
--- 3746,3752 ----
        return gen_rtx_LO_SUM (Pmode, reg, x);
      }
    else if (TARGET_TOC
+ 	   && GET_CODE (x) == SYMBOL_REF
  	   && constant_pool_expr_p (x)
  	   && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), Pmode))
      {
*************** rs6000_legitimize_reload_address (rtx x,
*** 4191,4196 ****
--- 4191,4197 ----
      }
  
    if (TARGET_TOC
+       && GET_CODE (x) == SYMBOL_REF
        && constant_pool_expr_p (x)
        && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (x), mode))
      {
*************** rs6000_emit_move (rtx dest, rtx source, 
*** 5041,5046 ****
--- 5042,5048 ----
  	  operands[1] = force_const_mem (mode, operands[1]);
  
  	  if (TARGET_TOC
+ 	      && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
  	      && constant_pool_expr_p (XEXP (operands[1], 0))
  	      && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (
  			get_pool_constant (XEXP (operands[1], 0)),

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