From d3010d7286ad5f894ef662ea189c201f2a724290 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 11 Apr 2005 18:25:08 +0000 Subject: [PATCH] alias-1.c: New test. 2005-04-11 Andrew Pinski * gcc.dg/tree-ssa/alias-1.c: New test. 2005-04-11 Andrew Pinski * tree-ssa-alias.c (may_alias_p): If the variable is a global variable and the pointer is parameter and -fargument-noalias-global is used, then the pointer cannot alias the variable. From-SVN: r97978 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/tree-ssa/alias-1.c | 16 ++++++++++++++++ gcc/tree-ssa-alias.c | 10 ++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/alias-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f4c65af..2c71954 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-04-11 Andrew Pinski + + * tree-ssa-alias.c (may_alias_p): If the variable + is a global variable and the pointer is parameter + and -fargument-noalias-global is used, then + the pointer cannot alias the variable. + 2005-04-11 James A. Morrison * config/sparc/sparc.c: Use gcc_assert and gcc_unreachable. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 50d11b6..ff03dbe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-04-11 Andrew Pinski + + * gcc.dg/tree-ssa/alias-1.c: New test. + 2005-04-11 Diego Novillo PR tree-optimization/20920 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-1.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-1.c new file mode 100644 index 0000000..4e6cc5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-1.c @@ -0,0 +1,16 @@ +/* { dg-options "-O2 -fargument-noalias-global -fdump-tree-optimizated" } */ +int f; +void link_error (); + +void g(int *i) +{ + *i = 0; + f = 1; + if (*i != 0) + link_error (); +} + + +/* We should have removed the link_error on the tree level as we told GCC + that *i cannot point to f via the option -fargument-noalias-global. */ +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"} } */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index de39ed1..0f70017 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1708,6 +1708,16 @@ may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set, alias_stats.simple_resolved++; return false; } + + /* If -fargument-noalias-global is >1, pointer arguments may + not point to global variables. */ + if (flag_argument_noalias > 1 && is_global_var (var) + && TREE_CODE (ptr) == PARM_DECL) + { + alias_stats.alias_noalias++; + alias_stats.simple_resolved++; + return false; + } m_ann = var_ann (mem); -- 2.7.4