OSDN Git Service

PR tree-optimization/47179
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jan 2011 20:13:56 +0000 (20:13 +0000)
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Jan 2011 20:13:56 +0000 (20:13 +0000)
* config/spu/spu.c (spu_ref_may_alias_errno): New function.
(TARGET_REF_MAY_ALIAS_ERRNO): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168961 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/spu/spu.c

index 678f393..00c85f8 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-18  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       PR tree-optimization/47179
+       * config/spu/spu.c (spu_ref_may_alias_errno): New function.
+       (TARGET_REF_MAY_ALIAS_ERRNO): Define.
+
 2011-01-18  Richard Guenther  <rguenther@suse.de>
 
        PR rtl-optimization/47216
index e141a15..324ac4d 100644 (file)
@@ -230,6 +230,7 @@ static void spu_unique_section (tree, int);
 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;
@@ -491,6 +492,9 @@ static const struct attribute_spec spu_attribute_table[] =
 #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
@@ -7150,4 +7154,28 @@ spu_function_profiler (FILE * file, int labelno ATTRIBUTE_UNUSED)
   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"