[PATCH, SPU] Fix PR47179 (Re: [PATCH] Prepare for a fix for PR47179)

Ulrich Weigand uweigand@de.ibm.com
Tue Jan 18 16:38:00 GMT 2011


Richard Guenther wrote:
> On Tue, 18 Jan 2011, Ulrich Weigand wrote:
> > I can try matching the DECL_ASSEMBLER_NAME; I guess the _impure_data
> > name is now part of the ABI anyway.  I was unable to find any function
> > called ao_ref_offset, however ... am I missing something?
> 
> I did.  It's simply ref->offset, valid after ao_ref_base has been called.

Ah, I see.  The patch below implements the suggestions above, and still
fixes the errno-1.c testcase on SPU.

I'm planning to commit this once testing completes.

Thanks,
Ulrich

ChangeLog:

	PR tree-optimization/47179
	* config/spu/spu.c (spu_ref_may_alias_errno): New function.
	(TARGET_REF_MAY_ALIAS_ERRNO): Define.


Index: gcc/config/spu/spu.c
===================================================================
*** gcc/config/spu/spu.c	(revision 168909)
--- gcc/config/spu/spu.c	(working copy)
*************** static void spu_unique_section (tree, in
*** 230,235 ****
--- 230,236 ----
  static rtx spu_expand_load (rtx, rtx, rtx, int);
  static void spu_trampoline_init (rtx, tree, rtx);
  static void spu_conditional_register_usage (void);
+ static bool spu_ref_may_alias_errno (ao_ref *);
  
  /* Which instruction set architecture to use.  */
  int spu_arch;
*************** static const struct attribute_spec spu_a
*** 491,496 ****
--- 492,500 ----
  #undef TARGET_CONDITIONAL_REGISTER_USAGE
  #define TARGET_CONDITIONAL_REGISTER_USAGE spu_conditional_register_usage
  
+ #undef TARGET_REF_MAY_ALIAS_ERRNO
+ #define TARGET_REF_MAY_ALIAS_ERRNO spu_ref_may_alias_errno
+ 
  struct gcc_target targetm = TARGET_INITIALIZER;
  
  static void
*************** spu_function_profiler (FILE * file, int 
*** 7150,7153 ****
--- 7154,7181 ----
    fprintf (file, "brsl $75,  _mcount\n");
  }
  
+ /* Implement targetm.ref_may_alias_errno.  */
+ static bool
+ spu_ref_may_alias_errno (ao_ref *ref)
+ {
+   tree base = ao_ref_base (ref);
+ 
+   /* With SPU newlib, errno is defined as something like
+          _impure_data._errno
+      The default implementation of this target macro does not
+      recognize such expressions, so special-code for it here.  */
+ 
+   if (TREE_CODE (base) == VAR_DECL
+       && !TREE_STATIC (base)
+       && DECL_EXTERNAL (base)
+       && TREE_CODE (TREE_TYPE (base)) == RECORD_TYPE
+       && strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (base)),
+ 		 "_impure_data") == 0
+       /* _errno is the first member of _impure_data.  */
+       && ref->offset == 0)
+     return true;
+ 
+   return default_ref_may_alias_errno (ref);
+ }
+ 
  #include "gt-spu.h"


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com



More information about the Gcc-patches mailing list