diff mbox

POWERPC64_TOC_POINTER_ALIGNMENT

Message ID 20151118215439.GA8546@ibm-tiger.the-meissners.org
State New
Headers show

Commit Message

Michael Meissner Nov. 18, 2015, 9:54 p.m. UTC
On Wed, Nov 18, 2015 at 10:35:36AM -0500, David Edelsohn wrote:
> On Tue, Nov 17, 2015 at 9:32 PM, Alan Modra <amodra@gmail.com> wrote:
> > On Tue, Nov 17, 2015 at 07:53:18PM -0500, Michael Meissner wrote:
> >> Here is the temporary patch I'm using to get past rs6000.c.  But I suspect the
> >> TOC alignment should never be 256.
> >
> > Yes, it should be.  Recent GNU ld aligns .TOC. to a 256 byte boundary.
> > I have this patch in my tree.
> >
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index abc8eaa..e3ec042 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -8059,12 +8059,17 @@ rs6000_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
> >  static bool
> >  use_toc_relative_ref (rtx sym, machine_mode mode)
> >  {
> > +  /* Silence complaint that the POWERPC64_TOC_POINTER_ALIGNMENT test
> > +     is always true.  */
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wtype-limits"
> >    return ((constant_pool_expr_p (sym)
> >            && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (sym),
> >                                                get_pool_mode (sym)))
> >           || (TARGET_CMODEL == CMODEL_MEDIUM
> >               && SYMBOL_REF_LOCAL_P (sym)
> >               && GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT));
> > +#pragma GCC diagnostic pop
> >  }
> >
> >  /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS.  Returns a value to
> 
> I have applied Alan's work-around for now until there is a more robust solution.
> 
> Thanks, David
> 

Note, the patch that was applied breaks being compiled with older compilers,
such as the GCC 4.4.7 compiler that is installed on my x86_64 laptop, and which
I build powerpc cross compilers from.  The older GCC does not allow these
pragmas to be used in the middle of a function.

I think the following patch should be applied to move the #pragmas outside of
the function.

Note, you will need the patch that is attached to PR 68393 in order to
bootstrap the compiler.

2015-11-18  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000.c (use_toc_relative_ref): Move #pragmas
	outside of the function to accomidate older GCC's.
diff mbox

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 230573)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -7991,22 +7991,24 @@  rs6000_cannot_force_const_mem (machine_m
    that we have put in the TOC, or for cmodel=medium, if the SYMBOL_REF
    can be addressed relative to the toc pointer.  */
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wtype-limits"
+
 static bool
 use_toc_relative_ref (rtx sym, machine_mode mode)
 {
 /* Silence complaint that the POWERPC64_TOC_POINTER_ALIGNMENT test
    is always true.  */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
   return ((constant_pool_expr_p (sym)
 	   && ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (get_pool_constant (sym),
 					       get_pool_mode (sym)))
 	  || (TARGET_CMODEL == CMODEL_MEDIUM
 	      && SYMBOL_REF_LOCAL_P (sym)
 	      && GET_MODE_SIZE (mode) <= POWERPC64_TOC_POINTER_ALIGNMENT));
-#pragma GCC diagnostic pop
 }
 
+#pragma GCC diagnostic pop
+
 /* Our implementation of LEGITIMIZE_RELOAD_ADDRESS.  Returns a value to
    replace the input X, or the original X if no replacement is called for.
    The output parameter *WIN is 1 if the calling macro should goto WIN,