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] Fix powerpc64-linux bootstrap with PR42861 fix


On Mon, Jan 25, 2010 at 05:49:40PM -0200, Alexandre Oliva wrote:
> At some point, I figured we could make do without adding bindings of
> VALUEs to their initialization expressions in variable tables, because
> the locations in cselib would be enough.  As the testcase shows, they
> aren't.
> 
> Here's a patch that Jakub kindly regstrapped on x86_64-linux-gnu and
> i686-linux-gnu.  Ok to install?

> for  gcc/ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	PR debug/42861
> 	* var-tracking.c (val_store): Add modified argument, obey it.
> 	Adjust callers.
> 	(count_uses): Move down logging of main.
> 	(compute_bb_dataflow): Use val_store for MO_VAL_USEs that
> 	don't need resolution.
> 	(emit_notes_in_bb): Likewise.

Unfortunately this patch broke bootstrap on powerpc64-linux.
As discussed in the PR, the problem is that assembler refuses to assemble
 .LLST3:
         .8byte  .LVL1-.Ltext0    # Location list begin address (*.LLST3)
         .8byte  .LVL7-.Ltext0    # Location list end address (*.LLST3)
         .2byte  0x1      # Location expression size
         .byte   0x59     # DW_OP_reg9
         .8byte  .LVL7-.Ltext0    # Location list begin address (*.LLST3)
         .8byte  .LVL9-1-.Ltext0  # Location list end address (*.LLST3)
         .2byte  0xc      # Location expression size
         .byte   0x72     # DW_OP_breg2
         .byte   0x0      # sleb128 0
         .byte   0x3      # DW_OP_addr
         .8byte  .LC2@toc
         .byte   0x22     # DW_OP_plus
         .8byte  0x0      # Location list terminator begin (*.LLST3)
         .8byte  0x0      # Location list terminator end (*.LLST3)
in .debug_loc section (in particular the .8byte .LC2@toc).
The problem is that powerpc lacks its own delegitimize hook.
When some optimized out variable holds an address of some other variable,
while that address is in some register all is fine, but when that register
is reused, yet the optimized out variable is supposed to be still live,
var-tracking figures out it is still available in memory at reg2+.LC2@toc.
On e.g. i?86/x86_64 or s390{,x} the delegitimize hook takes care of
simplifying that address back, and that's what the following patch does
also for powerpc.  This fixes the bootstrap on powerpc64-linux
--with-cpu=default32 on the trunk (and both --with-cpu=default32 and
--with-cpu=default64 in the 4.4-RH backport), and has been regtested there
as well.  Ok for trunk?

2010-01-27  Jakub Jelinek  <jakub@redhat.com>

	* config/rs6000/rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Redefine.
	(rs6000_delegitimize_address): New function.

--- gcc/config/rs6000/rs6000.c.jj	2010-01-09 21:31:46.000000000 +0100
+++ gcc/config/rs6000/rs6000.c	2010-01-26 15:13:35.000000000 +0100
@@ -1009,6 +1009,7 @@ rtx (*rs6000_legitimize_address_ptr) (rt
   = rs6000_legitimize_address;
 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
+static rtx rs6000_delegitimize_address (rtx);
 static rtx rs6000_tls_get_addr (void);
 static rtx rs6000_got_sym (void);
 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
@@ -1258,6 +1259,9 @@ static const char alt_reg_names[][8] =
 #undef TARGET_CANNOT_FORCE_CONST_MEM
 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
 
+#undef TARGET_DELEGITIMIZE_ADDRESS
+#define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
+
 #undef TARGET_ASM_FUNCTION_PROLOGUE
 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
 #undef TARGET_ASM_FUNCTION_EPILOGUE
@@ -5103,6 +5107,41 @@ rs6000_output_dwarf_dtprel (FILE *file, 
   fputs ("@dtprel+0x8000", file);
 }
 
+/* In the name of slightly smaller debug output, and to cater to
+   general assembler lossage, recognize various UNSPEC sequences
+   and turn them back into a direct symbol reference.  */
+
+static rtx
+rs6000_delegitimize_address (rtx orig_x)
+{
+  rtx x, y;
+
+  orig_x = delegitimize_mem_from_attrs (orig_x);
+  x = orig_x;
+  if (MEM_P (x))
+    x = XEXP (x, 0);
+
+  if (GET_CODE (x) == PLUS
+      && GET_CODE (XEXP (x, 1)) == CONST
+      && GET_CODE (XEXP (x, 0)) == REG
+      && REGNO (XEXP (x, 0)) == TOC_REGISTER)
+    {
+      y = XEXP (XEXP (x, 1), 0);
+      if (GET_CODE (y) == UNSPEC
+          && XINT (y, 1) == UNSPEC_TOCREL)
+	{
+	  y = XVECEXP (y, 0, 0);
+	  if (!MEM_P (orig_x))
+	    return y;
+	  else
+	    return replace_equiv_address_nv (orig_x, y);
+	}
+      return orig_x;
+    }
+
+  return orig_x;
+}
+
 /* Construct the SYMBOL_REF for the tls_get_addr function.  */
 
 static GTY(()) rtx rs6000_tls_symbol;


	Jakub


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