diff options
author | Martin Sebor <msebor@redhat.com> | 2019-11-12 18:49:31 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-11-12 11:49:31 -0700 |
commit | 1cf83d35b8cc41e88504b38e7f4d182ee1476003 (patch) | |
tree | a742c38dd6d5945907aedef8f840b613ef15f311 /gcc/targhooks.c | |
parent | 937a86b49e4ed8ef72c1384d617feff26580a048 (diff) |
PR tree-optimization/92412 - excessive errno aliasing assumption defeats optimization
gcc/ChangeLog:
PR tree-optimization/92412
* targhooks.c (default_ref_may_alias_errno): Errono can only alias
extern variables.
gcc/testsuite/ChangeLog:
PR tree-optimization/92412
* gcc.dg/strlenopt-91.c: New test.
From-SVN: r278099
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r-- | gcc/targhooks.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 822a0313e9e..b6443d204a6 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1414,9 +1414,11 @@ default_ref_may_alias_errno (ao_ref *ref) 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. */ + /* The default implementation assumes an errno location declaration + is never defined in the current compilation unit and may not be + aliased by a local variable. */ if (DECL_P (base) + && DECL_EXTERNAL (base) && !TREE_STATIC (base)) return true; else if (TREE_CODE (base) == MEM_REF |