diff options
author | Richard Guenther <rguenther@suse.de> | 2011-01-14 15:02:20 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-01-14 15:02:20 +0000 |
commit | 7352c013323c184875acec7bde645c99b7c18b9b (patch) | |
tree | e8806b70dd48d5f2e48f1df1922bb15787ffe2ba /gcc/targhooks.c | |
parent | 9a6c928887f6ae52f45a74f4aa54dd946c9c97d7 (diff) | |
download | gcc-7352c013323c184875acec7bde645c99b7c18b9b.zip gcc-7352c013323c184875acec7bde645c99b7c18b9b.tar.gz gcc-7352c013323c184875acec7bde645c99b7c18b9b.tar.bz2 |
re PR tree-optimization/47179 (SPU: errno misoptimization around malloc call)
2011-01-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47179
* target.def (ref_may_alias_errno): New target hook.
* targhooks.h (default_ref_may_alias_errno): Declare.
* targhooks.c: Include tree-ssa-alias.h and tree-flow.h.
(default_ref_may_alias_errno): New function.
* target.h (struct ao_ref_s): Declare.
* tree-ssa-alias.c: Include target.h.
(call_may_clobber_ref_p_1): Use the ref_may_alias_errno target hook.
* Makefile.in (tree-ssa-alias.o): Adjust dependencies.
(targhooks.o): Likewise.
* doc/tm.texi.in (TARGET_REF_MAY_ALIAS_ERRNO): Document.
* doc/tm.texi (TARGET_REF_MAY_ALIAS_ERRNO): Copy documentation.
From-SVN: r168788
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r-- | gcc/targhooks.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 30a5891..225831b 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -69,6 +69,8 @@ along with GCC; see the file COPYING3. If not see #include "recog.h" #include "intl.h" #include "opts.h" +#include "tree-flow.h" +#include "tree-ssa-alias.h" bool @@ -1035,6 +1037,33 @@ default_valid_pointer_mode (enum machine_mode mode) return (mode == ptr_mode || mode == Pmode); } +/* Determine whether the memory reference specified by REF may alias + the C libraries errno location. */ +bool +default_ref_may_alias_errno (ao_ref *ref) +{ + tree base = ao_ref_base (ref); + /* The default implementation assumes the errno location is + a declaration of type int or is always accessed via a + pointer to int. We assume that accesses to errno are + not deliberately obfuscated (even in conforming ways). */ + if (TYPE_UNSIGNED (TREE_TYPE (base)) + || TYPE_MODE (TREE_TYPE (base)) != TYPE_MODE (integer_type_node)) + return false; + /* The default implementation assumes an errno location + declaration is never defined in the current compilation unit. */ + if (DECL_P (base) + && !TREE_STATIC (base)) + return true; + else if (TREE_CODE (base) == MEM_REF + && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME) + { + struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0)); + return !pi || pi->pt.anything || pi->pt.nonlocal; + } + return false; +} + /* Return the mode for a pointer to a given ADDRSPACE, defaulting to ptr_mode for the generic address space only. */ |