diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2011-01-18 20:13:56 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@gcc.gnu.org> | 2011-01-18 20:13:56 +0000 |
commit | d4f2460a1bbcf6be3414aa26e79fa4a3fbb3716c (patch) | |
tree | d7ddfb12047858f67b8fa8a0f95d6b4b596069f0 /gcc | |
parent | 842627b60624602d0c486f8470e83c0d8039bf60 (diff) | |
download | gcc-d4f2460a1bbcf6be3414aa26e79fa4a3fbb3716c.zip gcc-d4f2460a1bbcf6be3414aa26e79fa4a3fbb3716c.tar.gz gcc-d4f2460a1bbcf6be3414aa26e79fa4a3fbb3716c.tar.bz2 |
re PR tree-optimization/47179 (SPU: errno misoptimization around malloc call)
PR tree-optimization/47179
* config/spu/spu.c (spu_ref_may_alias_errno): New function.
(TARGET_REF_MAY_ALIAS_ERRNO): Define.
From-SVN: r168961
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/spu/spu.c | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 678f393..00c85f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index e141a15..324ac4d 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -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" |