public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Revert "Handle builtins"
@ 2020-10-10 19:49 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2020-10-10 19:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:18569e271505684c8f9a5c33d34e2fa03cb8a3a4

commit 18569e271505684c8f9a5c33d34e2fa03cb8a3a4
Author: Jan Hubicka <jh@suse.cz>
Date:   Sat Oct 10 21:45:51 2020 +0200

    Revert "Handle builtins"
    
    This reverts commit 75f27a872e94cbe2e661d58d527d42140ea30424.

Diff:
---
 gcc/ipa-modref.c     | 249 ++-----------
 gcc/ipa-modref.h     |   1 -
 gcc/tree-ssa-alias.c | 975 +++++++++++++++++++++------------------------------
 gcc/tree-ssa-alias.h |  28 --
 4 files changed, 431 insertions(+), 822 deletions(-)

diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 427079dca78..3983b972060 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -59,7 +59,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "value-range.h"
 #include "ipa-prop.h"
 #include "ipa-fnsummary.h"
-#include "tree-ssa-alias.h"
 
 /* Class (from which there is one global instance) that holds modref summaries
    for all analyzed functions.  */
@@ -258,8 +257,6 @@ modref_summary::dump (FILE *out)
       fprintf (out, "  LTO stores:\n");
       dump_lto_records (stores_lto, out);
     }
-  if (writes_errno)
-    fprintf (out, "  Writes errno\n");
 }
 
 
@@ -440,35 +437,6 @@ ignore_stores_p (tree caller, int flags)
   return false;
 }
 
-/* Return parm map value for OP.
-   This means returning nonnegative value if OP is function parameter,
-   -2 is OP points to local or readonly memory and -1 otherwise.  */
-static int
-parm_map_for (tree op)
-{
-  if (TREE_CODE (op) == SSA_NAME
-      && SSA_NAME_IS_DEFAULT_DEF (op)
-      && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
-    {
-      int index = 0;
-      for (tree t = DECL_ARGUMENTS (current_function_decl);
-	   t != SSA_NAME_VAR (op); t = DECL_CHAIN (t))
-	{
-	  if (!t)
-	    {
-	      index = -1;
-	      break;
-	    }
-	  index++;
-	}
-      return index;
-    }
-  else if (points_to_local_or_readonly_memory_p (op))
-    return -2;
-  else
-    return -1;
-}
-
 /* Merge side effects of call STMT to function with CALLEE_SUMMARY
    int CUR_SUMMARY.  Return true if something changed.
    If IGNORE_STORES is true, do not merge stores.  */
@@ -484,7 +452,29 @@ merge_call_side_effects (modref_summary *cur_summary,
   parm_map.safe_grow (gimple_call_num_args (stmt));
   for (unsigned i = 0; i < gimple_call_num_args (stmt); i++)
     {
-      parm_map[i] = parm_map_for (gimple_call_arg (stmt, i));
+      tree op = gimple_call_arg (stmt, i);
+      STRIP_NOPS (op);
+      if (TREE_CODE (op) == SSA_NAME
+	  && SSA_NAME_IS_DEFAULT_DEF (op)
+	  && TREE_CODE (SSA_NAME_VAR (op)) == PARM_DECL)
+	{
+	  int index = 0;
+	  for (tree t = DECL_ARGUMENTS (current_function_decl);
+	       t != SSA_NAME_VAR (op); t = DECL_CHAIN (t))
+	    {
+	      if (!t)
+		{
+		  index = -1;
+		  break;
+		}
+	      index++;
+	    }
+	  parm_map[i] = index;
+	}
+      else if (points_to_local_or_readonly_memory_p (op))
+	parm_map[i] = -2;
+      else
+	parm_map[i] = -1;
     }
 
   /* Merge with callee's summary.  */
@@ -554,85 +544,6 @@ analyze_call (modref_summary *cur_summary,
       return false;
     }
 
-  struct ao_function_info info;
-  if (callee
-      && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)
-      && ao_classify_builtin (callee, &info)
-      && !(info.flags & AO_FUNCTION_BARRIER))
-    {
-      bool collapse_loads = false, collapse_stores = false;
-      if (info.num_param_reads >= 0)
-	{
-	  for (int i = 0; i < info.num_param_reads && !collapse_loads; i++)
-	    {
-	      int map = parm_map_for
-			  (gimple_call_arg (stmt,
-					    info.reads[i].param));
-	      if (map == -2)
-		continue;
-	      else if (map == -1)
-		collapse_loads = true;
-	      else
-		{
-		  modref_access_node a = {map};
-		  if (cur_summary->loads)
-		    cur_summary->loads->insert (0, 0, a);
-		  if (cur_summary->loads_lto)
-		    cur_summary->loads_lto->insert (NULL, NULL, a);
-		}
-	    }
-	}
-      else
-	collapse_loads = true;
-      if (collapse_loads)
-	{
-	  if (cur_summary->loads)
-	    cur_summary->loads->collapse ();
-	  if (cur_summary->loads_lto)
-	    cur_summary->loads_lto->collapse ();
-	}
-      if (ignore_stores)
-	;
-      else if (info.num_param_writes >= 0)
-	{
-	  if ((info.flags & AO_FUNCTION_ERRNO) && flag_errno_math)
-	    cur_summary->writes_errno = true;
-	  for (int i = 0; i < info.num_param_writes && !collapse_stores;
-	       i++)
-	    {
-	      int map = parm_map_for
-			  (gimple_call_arg (stmt,
-					    info.writes[i].param));
-	      if (map == -2)
-		continue;
-	      else if (map == -1)
-		collapse_stores = true;
-	      else
-		{
-		  modref_access_node a = {map};
-		  if (cur_summary->stores)
-		    cur_summary->stores->insert (0, 0, a);
-		  if (cur_summary->stores_lto)
-		    cur_summary->stores_lto->insert (NULL, NULL, a);
-		}
-	    }
-	}
-      else
-	collapse_stores = true;
-
-      if (collapse_stores)
-	{
-	  if (cur_summary->stores)
-	    cur_summary->stores->collapse ();
-	  if (cur_summary->stores_lto)
-	    cur_summary->stores_lto->collapse ();
-	}
-      return true;
-    }
-  else if (dump_file && gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
-    fprintf (dump_file, "      Unclassified builtin %s\n",
-	     IDENTIFIER_POINTER (DECL_NAME (callee)));
-
   struct cgraph_node *callee_node = cgraph_node::get_create (callee);
 
   /* We can not safely optimize based on summary of callee if it does
@@ -861,7 +772,6 @@ analyze_function (function *f, bool ipa)
 				  param_modref_max_accesses);
     }
   summary->finished = false;
-  summary->writes_errno = false;
   int ecf_flags = flags_from_decl_or_type (current_function_decl);
   auto_vec <gimple *, 32> recursive_calls;
 
@@ -962,7 +872,6 @@ modref_summaries::duplicate (cgraph_node *, cgraph_node *,
 			     modref_summary *dst_data)
 {
   dst_data->finished = src_data->finished;
-  dst_data->writes_errno = src_data->writes_errno;
   if (src_data->stores)
     {
       dst_data->stores = modref_records::create_ggc
@@ -1242,7 +1151,6 @@ modref_write ()
 	    write_modref_records (r->loads_lto, ob);
 	  if (r->stores_lto)
 	    write_modref_records (r->stores_lto, ob);
-	  streamer_write_uhwi (ob, r->writes_errno);
 	}
     }
   streamer_write_char_stream (ob->main_stream, 0);
@@ -1296,7 +1204,6 @@ read_section (struct lto_file_decl_data *file_data, const char *data,
 	 read_modref_records (&ib, data_in,
 			      &modref_sum->stores,
 			      &modref_sum->stores_lto);
-      modref_sum->writes_errno = streamer_read_uhwi (&ib);
       if (dump_file)
 	{
 	  fprintf (dump_file, "Read modref for %s\n",
@@ -1565,28 +1472,6 @@ collapse_loads (modref_summary *cur_summary)
   return changed;
 }
 
-/* Collapse stores and return true if something changed.  */
-
-bool
-collapse_stores (modref_summary *cur_summary)
-{
-  bool changed = false;
-
-  if (cur_summary->stores && !cur_summary->stores->every_base)
-    {
-      cur_summary->stores->collapse ();
-      changed = true;
-    }
-  if (cur_summary->stores_lto
-      && !cur_summary->stores_lto->every_base)
-    {
-      cur_summary->stores_lto->collapse ();
-      changed = true;
-    }
-  return changed;
-}
-
-
 /* Perform iterative dataflow on SCC component starting in COMPONENT_NODE.  */
 
 static void
@@ -1667,94 +1552,6 @@ modref_propagate_in_scc (cgraph_node *component_node)
 			 callee_edge->callee->dump_name ());
 
 	      bool ignore_stores = ignore_stores_p (cur->decl, flags);
-	      struct ao_function_info info;
-	      if (callee
-		  && fndecl_built_in_p (callee->decl, BUILT_IN_NORMAL)
-		  && ao_classify_builtin (callee->decl, &info)
-		  && !(info.flags & AO_FUNCTION_BARRIER))
-		{
-		  bool collapse_loads_p = false, collapse_stores_p = false;
-		  auto_vec <int, 32> parm_map;
-
-		  compute_parm_map (callee_edge, &parm_map);
-
-		  if (info.num_param_reads >= 0)
-		    {
-		      for (int i = 0; i < info.num_param_reads
-			   && !collapse_loads_p; i++)
-			{
-			  int map = i < (int) parm_map.length ()
-				    ? parm_map[i] : -1;
-
-			  if (dump_file && i >= (int) parm_map.length ())
-			    fprintf (dump_file, "      Untracked param %i\n",
-				     i);
-
-			  if (map == -2)
-			    continue;
-			  else if (map == -1)
-			    collapse_loads_p = true;
-			  else
-			    {
-			      modref_access_node a = {map};
-			      if (cur_summary->loads)
-				changed |= cur_summary->loads->insert (0, 0, a);
-			      if (cur_summary->loads_lto)
-				changed |= cur_summary->loads_lto->insert
-						 (NULL, NULL, a);
-			    }
-			}
-		    }
-		  else
-		    collapse_loads_p = true;
-		  if (collapse_loads_p)
-		    changed |= collapse_loads (cur_summary);
-		  if (ignore_stores)
-		    ;
-		  else if (info.num_param_writes >= 0)
-		    {
-		      if ((info.flags & AO_FUNCTION_ERRNO) && flag_errno_math)
-			cur_summary->writes_errno = true;
-		      for (int i = 0;
-			   i < info.num_param_writes && !collapse_stores_p;
-			   i++)
-			{
-			  int map = i < (int) parm_map.length ()
-				    ? parm_map[i] : -1;
-
-			  if (dump_file && i >= (int) parm_map.length ())
-			    fprintf (dump_file, "      Untracked param %i\n",
-				     i);
-
-			  if (map == -2)
-			    continue;
-			  else if (map == -1)
-			    collapse_stores_p = true;
-			  else
-			    {
-			      modref_access_node a = {map};
-			      if (cur_summary->stores)
-				changed |= cur_summary->stores->insert
-					       (0, 0, a);
-			      if (cur_summary->stores_lto)
-				changed |= cur_summary->stores_lto->insert
-						(NULL, NULL, a);
-			    }
-			}
-		    }
-		  else
-		    collapse_stores_p = true;
-
-		  if (collapse_stores_p)
-		    changed |= collapse_stores (cur_summary);
-
-		  continue;
-		}
-	      else if (dump_file && callee
-		       && fndecl_built_in_p (callee->decl, BUILT_IN_NORMAL))
-		fprintf (dump_file, "      Unclassified builtin %s\n",
-			 IDENTIFIER_POINTER (DECL_NAME (callee->decl)));
-
 
 	      /* We don't know anything about CALLEE, hence we cannot tell
 		 anything about the entire component.  */
diff --git a/gcc/ipa-modref.h b/gcc/ipa-modref.h
index a9c71800750..b6621b498f0 100644
--- a/gcc/ipa-modref.h
+++ b/gcc/ipa-modref.h
@@ -37,7 +37,6 @@ struct GTY(()) modref_summary
   modref_records_lto *loads_lto;
   modref_records_lto *stores_lto;
   bool finished;
-  bool writes_errno;
 
   modref_summary ();
   ~modref_summary ();
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index d7baaf77e94..65f2a67a095 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2503,507 +2503,6 @@ modref_may_conflict (const gimple *stmt,
   return false;
 }
 
-/* If CALLEE has known side effects, fill in INFO and return true.
-   See tree-ssa-structalias.c:find_func_aliases
-   for the list of builtins we might need to handle here.  */
-
-bool
-ao_classify_builtin (tree callee, ao_function_info *info)
-{
-  built_in_function code = DECL_FUNCTION_CODE (callee);
-
-  switch (code)
-    {
-      /* All the following functions read memory pointed to by
-	 their second argument and write memory pointed to by first
-	 argument.
-	 strcat/strncat additionally reads memory pointed to by the first
-	 argument.  */
-      case BUILT_IN_STRCAT:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    2,				/* num_param_reads.  */
-
-		    /* Reads and write descriptors are triples containing:
-		       - index of parameter read
-		       - index of parameter specifying access size
-			 (-1 if unknown)
-		       - access size in bytes (0 if unkown).  */
-
-		    {{0, -1, 0}, {1, -1, 0}},	/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRNCAT:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    2,				/* num_param_reads.  */
-		    {{0, -1, 0}, {1, 2, 0}},	/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRCPY:
-      case BUILT_IN_STPCPY:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{1, -1, 0}},		/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRNCPY:
-      case BUILT_IN_MEMCPY:
-      case BUILT_IN_MEMMOVE:
-      case BUILT_IN_MEMPCPY:
-      case BUILT_IN_STPNCPY:
-      case BUILT_IN_TM_MEMCPY:
-      case BUILT_IN_TM_MEMMOVE:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{1, 2, 0}},		/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, 2, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRCAT_CHK:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    2,				/* num_param_reads.  */
-		    {{0, -1, 0}, {1, -1, 0}},	/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRNCAT_CHK:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    2,				/* num_param_reads.  */
-		    {{0, -1, 0}, {1, 2, 0}},	/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRCPY_CHK:
-      case BUILT_IN_STPCPY_CHK:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{1, -1, 0}},		/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRNCPY_CHK:
-      case BUILT_IN_MEMCPY_CHK:
-      case BUILT_IN_MEMMOVE_CHK:
-      case BUILT_IN_MEMPCPY_CHK:
-      case BUILT_IN_STPNCPY_CHK:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{1, 2, 0}},		/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, 2, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_BCOPY:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{0, 2, 0}},		/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{1, 2, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-
-      /* The following functions read memory pointed to by their
-	 first argument.  */
-      CASE_BUILT_IN_TM_LOAD (1):
-      CASE_BUILT_IN_TM_LOAD (2):
-      CASE_BUILT_IN_TM_LOAD (4):
-      CASE_BUILT_IN_TM_LOAD (8):
-      CASE_BUILT_IN_TM_LOAD (FLOAT):
-      CASE_BUILT_IN_TM_LOAD (DOUBLE):
-      CASE_BUILT_IN_TM_LOAD (LDOUBLE):
-      CASE_BUILT_IN_TM_LOAD (M64):
-      CASE_BUILT_IN_TM_LOAD (M128):
-      CASE_BUILT_IN_TM_LOAD (M256):
-      case BUILT_IN_TM_LOG:
-      case BUILT_IN_TM_LOG_1:
-      case BUILT_IN_TM_LOG_2:
-      case BUILT_IN_TM_LOG_4:
-      case BUILT_IN_TM_LOG_8:
-      case BUILT_IN_TM_LOG_FLOAT:
-      case BUILT_IN_TM_LOG_DOUBLE:
-      case BUILT_IN_TM_LOG_LDOUBLE:
-      case BUILT_IN_TM_LOG_M64:
-      case BUILT_IN_TM_LOG_M128:
-      case BUILT_IN_TM_LOG_M256:
-
-      case BUILT_IN_INDEX:
-      case BUILT_IN_STRCHR:
-      case BUILT_IN_STRRCHR:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    /* TODO: For TM builtins size is known.  */
-		    {{0, -1, 0}},		/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-
-      /* These read memory pointed to by the first argument.
-	 Allocating memory does not have any side-effects apart from
-	 being the definition point for the pointer.
-	 Unix98 specifies that errno is set on allocation failure.  */
-      case BUILT_IN_STRDUP:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{0, -1, 0}},		/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STRNDUP:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{0, 1, 0}},		/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* Allocating memory does not have any side-effects apart from
-	 being the definition point for the pointer.  */
-      case BUILT_IN_MALLOC:
-      case BUILT_IN_ALIGNED_ALLOC:
-      case BUILT_IN_CALLOC:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* These read memory pointed to by the first argument with size
-	 in the third argument.  */
-      case BUILT_IN_MEMCHR:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{0, 2, 0}},		/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* These read memory pointed to by the first and second arguments.  */
-      case BUILT_IN_STRSTR:
-      case BUILT_IN_STRPBRK:
-	{
-	  static struct ao_function_info ret_info
-	       = {
-		    2,				/* num_param_reads.  */
-		    {{0, -1, 0}, {1, -1, 0}},	/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* Freeing memory kills the pointed-to memory.  More importantly
-	 the call has to serve as a barrier for moving loads and stores
-	 across it.  */
-      case BUILT_IN_FREE:
-      case BUILT_IN_VA_END:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* Realloc serves both as allocation point and deallocation point.  */
-      case BUILT_IN_REALLOC:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    1,				/* num_param_reads.  */
-		    {{0, 1, 0}},		/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_GAMMA_R:
-      case BUILT_IN_GAMMAF_R:
-      case BUILT_IN_GAMMAL_R:
-      case BUILT_IN_LGAMMA_R:
-      case BUILT_IN_LGAMMAF_R:
-      case BUILT_IN_LGAMMAL_R:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{1, -1, 0}},		/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_FREXP:
-      case BUILT_IN_FREXPF:
-      case BUILT_IN_FREXPL:
-      case BUILT_IN_MODF:
-      case BUILT_IN_MODFF:
-      case BUILT_IN_MODFL:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{1, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_REMQUO:
-      case BUILT_IN_REMQUOF:
-      case BUILT_IN_REMQUOL:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{2, -1, 0}},		/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_SINCOS:
-      case BUILT_IN_SINCOSF:
-      case BUILT_IN_SINCOSL:
-	{
-	  static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {{1, -1, 0}, {2, -1, 0}},	/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  tree type = float_ptr_type_node;
-	  if (code == BUILT_IN_SINCOS)
-	    type = double_ptr_type_node;
-	  else
-	    type = long_double_ptr_type_node;
-	  ret_info.writes[0].size = ret_info.writes[1].size
-		 = tree_to_uhwi (TYPE_SIZE_UNIT (type));
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_MEMSET:
-      case BUILT_IN_MEMSET_CHK:
-      case BUILT_IN_TM_MEMSET:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    {0, 2, 0},			/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      CASE_BUILT_IN_TM_STORE (1):
-      CASE_BUILT_IN_TM_STORE (2):
-      CASE_BUILT_IN_TM_STORE (4):
-      CASE_BUILT_IN_TM_STORE (8):
-      CASE_BUILT_IN_TM_STORE (FLOAT):
-      CASE_BUILT_IN_TM_STORE (DOUBLE):
-      CASE_BUILT_IN_TM_STORE (LDOUBLE):
-      CASE_BUILT_IN_TM_STORE (M64):
-      CASE_BUILT_IN_TM_STORE (M128):
-      CASE_BUILT_IN_TM_STORE (M256):
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    1,				/* num_param_writes.  */
-		    /* TODO: Size is known.  */
-		    {0, -1, 0},			/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      case BUILT_IN_STACK_SAVE:
-      CASE_BUILT_IN_ALLOCA:
-      case BUILT_IN_ASSUME_ALIGNED:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* But posix_memalign stores a pointer into the memory pointed to
-	 by its first argument.  */
-      case BUILT_IN_POSIX_MEMALIGN:
-	{
-	  static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {{0, -1, 0}},		/* Param written.  */
-		    AO_FUNCTION_ERRNO,		/* flags.  */
-		 };
-	  ret_info.writes[0].size
-		 = tree_to_uhwi (TYPE_SIZE_UNIT (ptr_type_node));
-	  *info = ret_info;
-	  return true;
-	}
-      /* The following builtins do not read from memory.  */
-      case BUILT_IN_STACK_RESTORE:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    0,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    0,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    (ao_function_flags)0,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-      /* __sync_* builtins and some OpenMP builtins act as threading
-	 barriers.  */
-#undef DEF_SYNC_BUILTIN
-#define DEF_SYNC_BUILTIN(ENUM, NAME, TYPE, ATTRS) case ENUM:
-#include "sync-builtins.def"
-#undef DEF_SYNC_BUILTIN
-      case BUILT_IN_GOMP_ATOMIC_START:
-      case BUILT_IN_GOMP_ATOMIC_END:
-      case BUILT_IN_GOMP_BARRIER:
-      case BUILT_IN_GOMP_BARRIER_CANCEL:
-      case BUILT_IN_GOMP_TASKWAIT:
-      case BUILT_IN_GOMP_TASKGROUP_END:
-      case BUILT_IN_GOMP_CRITICAL_START:
-      case BUILT_IN_GOMP_CRITICAL_END:
-      case BUILT_IN_GOMP_CRITICAL_NAME_START:
-      case BUILT_IN_GOMP_CRITICAL_NAME_END:
-      case BUILT_IN_GOMP_LOOP_END:
-      case BUILT_IN_GOMP_LOOP_END_CANCEL:
-      case BUILT_IN_GOMP_ORDERED_START:
-      case BUILT_IN_GOMP_ORDERED_END:
-      case BUILT_IN_GOMP_SECTIONS_END:
-      case BUILT_IN_GOMP_SECTIONS_END_CANCEL:
-      case BUILT_IN_GOMP_SINGLE_COPY_START:
-      case BUILT_IN_GOMP_SINGLE_COPY_END:
-	{
-	  const static struct ao_function_info ret_info
-	       = {
-		    -1,				/* num_param_reads.  */
-		    {},				/* Param read.  */
-		    -1,				/* num_param_writes.  */
-		    {},				/* Param written.  */
-		    AO_FUNCTION_BARRIER,	/* flags.  */
-		 };
-	  *info = ret_info;
-	  return true;
-	}
-
-      default:
-	return false;
-    }
-}
-
 /* If the call CALL may use the memory reference REF return true,
    otherwise return false.  */
 
@@ -3075,37 +2574,219 @@ ref_maybe_used_by_call_p_1 (gcall *call, ao_ref *ref, bool tbaa_p)
   /* Handle those builtin functions explicitly that do not act as
      escape points.  See tree-ssa-structalias.c:find_func_aliases
      for the list of builtins we might need to handle here.  */
-  struct ao_function_info info;
   if (callee != NULL_TREE
-      && gimple_call_builtin_p (call, BUILT_IN_NORMAL)
-      && (ao_classify_builtin (callee, &info)))
-    {
-      if (info.flags & AO_FUNCTION_BARRIER)
-	return true;
-      if (info.num_param_reads >= 0)
-	{
-	  for (int i = 0; i < info.num_param_reads; i++)
-	    {
-	      ao_ref dref;
-	      tree size = NULL_TREE;
-
-	      gcc_checking_assert (info.reads[i].size_param
-				   != info.reads[i].param);
-	      if (info.reads[i].size_param != -1)
-		size = gimple_call_arg (call, info.reads[i].size);
-	      else if (info.reads[i].size)
-		size = build_int_cst (size_type_node, info.reads[i].size);
-	      ao_ref_init_from_ptr_and_size (&dref,
-					     gimple_call_arg
-						 (call,
-						  info.reads[i].param),
-					     size);
-	      if (refs_may_alias_p_1 (&dref, ref, tbaa_p))
-		return true;
-	    }
+      && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
+    switch (DECL_FUNCTION_CODE (callee))
+      {
+	/* All the following functions read memory pointed to by
+	   their second argument.  strcat/strncat additionally
+	   reads memory pointed to by the first argument.  */
+	case BUILT_IN_STRCAT:
+	case BUILT_IN_STRNCAT:
+	  {
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   NULL_TREE);
+	    if (refs_may_alias_p_1 (&dref, ref, false))
+	      return true;
+	  }
+	  /* FALLTHRU */
+	case BUILT_IN_STRCPY:
+	case BUILT_IN_STRNCPY:
+	case BUILT_IN_MEMCPY:
+	case BUILT_IN_MEMMOVE:
+	case BUILT_IN_MEMPCPY:
+	case BUILT_IN_STPCPY:
+	case BUILT_IN_STPNCPY:
+	case BUILT_IN_TM_MEMCPY:
+	case BUILT_IN_TM_MEMMOVE:
+	  {
+	    ao_ref dref;
+	    tree size = NULL_TREE;
+	    if (gimple_call_num_args (call) == 3)
+	      size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 1),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	case BUILT_IN_STRCAT_CHK:
+	case BUILT_IN_STRNCAT_CHK:
+	  {
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   NULL_TREE);
+	    if (refs_may_alias_p_1 (&dref, ref, false))
+	      return true;
+	  }
+	  /* FALLTHRU */
+	case BUILT_IN_STRCPY_CHK:
+	case BUILT_IN_STRNCPY_CHK:
+	case BUILT_IN_MEMCPY_CHK:
+	case BUILT_IN_MEMMOVE_CHK:
+	case BUILT_IN_MEMPCPY_CHK:
+	case BUILT_IN_STPCPY_CHK:
+	case BUILT_IN_STPNCPY_CHK:
+	  {
+	    ao_ref dref;
+	    tree size = NULL_TREE;
+	    if (gimple_call_num_args (call) == 4)
+	      size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 1),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	case BUILT_IN_BCOPY:
+	  {
+	    ao_ref dref;
+	    tree size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+
+	/* The following functions read memory pointed to by their
+	   first argument.  */
+	CASE_BUILT_IN_TM_LOAD (1):
+	CASE_BUILT_IN_TM_LOAD (2):
+	CASE_BUILT_IN_TM_LOAD (4):
+	CASE_BUILT_IN_TM_LOAD (8):
+	CASE_BUILT_IN_TM_LOAD (FLOAT):
+	CASE_BUILT_IN_TM_LOAD (DOUBLE):
+	CASE_BUILT_IN_TM_LOAD (LDOUBLE):
+	CASE_BUILT_IN_TM_LOAD (M64):
+	CASE_BUILT_IN_TM_LOAD (M128):
+	CASE_BUILT_IN_TM_LOAD (M256):
+	case BUILT_IN_TM_LOG:
+	case BUILT_IN_TM_LOG_1:
+	case BUILT_IN_TM_LOG_2:
+	case BUILT_IN_TM_LOG_4:
+	case BUILT_IN_TM_LOG_8:
+	case BUILT_IN_TM_LOG_FLOAT:
+	case BUILT_IN_TM_LOG_DOUBLE:
+	case BUILT_IN_TM_LOG_LDOUBLE:
+	case BUILT_IN_TM_LOG_M64:
+	case BUILT_IN_TM_LOG_M128:
+	case BUILT_IN_TM_LOG_M256:
+	  return ptr_deref_may_alias_ref_p_1 (gimple_call_arg (call, 0), ref);
+
+	/* These read memory pointed to by the first argument.  */
+	case BUILT_IN_STRDUP:
+	case BUILT_IN_STRNDUP:
+	case BUILT_IN_REALLOC:
+	  {
+	    ao_ref dref;
+	    tree size = NULL_TREE;
+	    if (gimple_call_num_args (call) == 2)
+	      size = gimple_call_arg (call, 1);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	/* These read memory pointed to by the first argument.  */
+	case BUILT_IN_INDEX:
+	case BUILT_IN_STRCHR:
+	case BUILT_IN_STRRCHR:
+	  {
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   NULL_TREE);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	/* These read memory pointed to by the first argument with size
+	   in the third argument.  */
+	case BUILT_IN_MEMCHR:
+	  {
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   gimple_call_arg (call, 2));
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	/* These read memory pointed to by the first and second arguments.  */
+	case BUILT_IN_STRSTR:
+	case BUILT_IN_STRPBRK:
+	  {
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   NULL_TREE);
+	    if (refs_may_alias_p_1 (&dref, ref, false))
+	      return true;
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 1),
+					   NULL_TREE);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+
+	/* The following builtins do not read from memory.  */
+	case BUILT_IN_FREE:
+	case BUILT_IN_MALLOC:
+	case BUILT_IN_POSIX_MEMALIGN:
+	case BUILT_IN_ALIGNED_ALLOC:
+	case BUILT_IN_CALLOC:
+	CASE_BUILT_IN_ALLOCA:
+	case BUILT_IN_STACK_SAVE:
+	case BUILT_IN_STACK_RESTORE:
+	case BUILT_IN_MEMSET:
+	case BUILT_IN_TM_MEMSET:
+	case BUILT_IN_MEMSET_CHK:
+	case BUILT_IN_FREXP:
+	case BUILT_IN_FREXPF:
+	case BUILT_IN_FREXPL:
+	case BUILT_IN_GAMMA_R:
+	case BUILT_IN_GAMMAF_R:
+	case BUILT_IN_GAMMAL_R:
+	case BUILT_IN_LGAMMA_R:
+	case BUILT_IN_LGAMMAF_R:
+	case BUILT_IN_LGAMMAL_R:
+	case BUILT_IN_MODF:
+	case BUILT_IN_MODFF:
+	case BUILT_IN_MODFL:
+	case BUILT_IN_REMQUO:
+	case BUILT_IN_REMQUOF:
+	case BUILT_IN_REMQUOL:
+	case BUILT_IN_SINCOS:
+	case BUILT_IN_SINCOSF:
+	case BUILT_IN_SINCOSL:
+	case BUILT_IN_ASSUME_ALIGNED:
+	case BUILT_IN_VA_END:
 	  return false;
-	}
-    }
+	/* __sync_* builtins and some OpenMP builtins act as threading
+	   barriers.  */
+#undef DEF_SYNC_BUILTIN
+#define DEF_SYNC_BUILTIN(ENUM, NAME, TYPE, ATTRS) case ENUM:
+#include "sync-builtins.def"
+#undef DEF_SYNC_BUILTIN
+	case BUILT_IN_GOMP_ATOMIC_START:
+	case BUILT_IN_GOMP_ATOMIC_END:
+	case BUILT_IN_GOMP_BARRIER:
+	case BUILT_IN_GOMP_BARRIER_CANCEL:
+	case BUILT_IN_GOMP_TASKWAIT:
+	case BUILT_IN_GOMP_TASKGROUP_END:
+	case BUILT_IN_GOMP_CRITICAL_START:
+	case BUILT_IN_GOMP_CRITICAL_END:
+	case BUILT_IN_GOMP_CRITICAL_NAME_START:
+	case BUILT_IN_GOMP_CRITICAL_NAME_END:
+	case BUILT_IN_GOMP_LOOP_END:
+	case BUILT_IN_GOMP_LOOP_END_CANCEL:
+	case BUILT_IN_GOMP_ORDERED_START:
+	case BUILT_IN_GOMP_ORDERED_END:
+	case BUILT_IN_GOMP_SECTIONS_END:
+	case BUILT_IN_GOMP_SECTIONS_END_CANCEL:
+	case BUILT_IN_GOMP_SINGLE_COPY_START:
+	case BUILT_IN_GOMP_SINGLE_COPY_END:
+	  return true;
+
+	default:
+	  /* Fallthru to general call handling.  */;
+      }
 
   /* Check if base is a global static variable that is not read
      by the function.  */
@@ -3280,9 +2961,7 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p)
 	  modref_summary *summary = get_modref_function_summary (node);
 	  if (summary)
 	    {
-	      if (!modref_may_conflict (call, summary->stores, ref, tbaa_p)
-		  && (!summary->writes_errno
-		      || !targetm.ref_may_alias_errno (ref)))
+	      if (!modref_may_conflict (call, summary->stores, ref, tbaa_p))
 		{
 		  alias_stats.modref_clobber_no_alias++;
 		  if (dump_file && (dump_flags & TDF_DETAILS))
@@ -3337,43 +3016,205 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref, bool tbaa_p)
       && SSA_NAME_POINTS_TO_READONLY_MEMORY (TREE_OPERAND (base, 0)))
     return false;
 
-  struct ao_function_info info;
   /* Handle those builtin functions explicitly that do not act as
-     escape points.  */
+     escape points.  See tree-ssa-structalias.c:find_func_aliases
+     for the list of builtins we might need to handle here.  */
   if (callee != NULL_TREE
-      && gimple_call_builtin_p (call, BUILT_IN_NORMAL)
-      && (ao_classify_builtin (callee, &info)))
-    {
-      if (info.flags & AO_FUNCTION_BARRIER)
-	return true;
-      if ((info.flags & AO_FUNCTION_ERRNO)
-	  && flag_errno_math
-	  && targetm.ref_may_alias_errno (ref))
-	return true;
-      if (info.num_param_writes >= 0)
-	{
-	  for (int i = 0; i < info.num_param_writes; i++)
-	    {
-	      ao_ref dref;
-	      tree size = NULL_TREE;
-
-	      gcc_checking_assert (info.writes[i].size_param
-				   != info.writes[i].param);
-	      if (info.writes[i].size_param != -1)
-		size = gimple_call_arg (call, info.writes[i].size_param);
-	      else if (info.writes[i].size)
-		size = build_int_cst (size_type_node, info.writes[i].size);
-	      ao_ref_init_from_ptr_and_size (&dref,
-					     gimple_call_arg
-						 (call,
-						  info.writes[i].param),
-					     size);
-	      if (refs_may_alias_p_1 (&dref, ref, tbaa_p))
-		return true;
-	    }
+      && gimple_call_builtin_p (call, BUILT_IN_NORMAL))
+    switch (DECL_FUNCTION_CODE (callee))
+      {
+	/* All the following functions clobber memory pointed to by
+	   their first argument.  */
+	case BUILT_IN_STRCPY:
+	case BUILT_IN_STRNCPY:
+	case BUILT_IN_MEMCPY:
+	case BUILT_IN_MEMMOVE:
+	case BUILT_IN_MEMPCPY:
+	case BUILT_IN_STPCPY:
+	case BUILT_IN_STPNCPY:
+	case BUILT_IN_STRCAT:
+	case BUILT_IN_STRNCAT:
+	case BUILT_IN_MEMSET:
+	case BUILT_IN_TM_MEMSET:
+	CASE_BUILT_IN_TM_STORE (1):
+	CASE_BUILT_IN_TM_STORE (2):
+	CASE_BUILT_IN_TM_STORE (4):
+	CASE_BUILT_IN_TM_STORE (8):
+	CASE_BUILT_IN_TM_STORE (FLOAT):
+	CASE_BUILT_IN_TM_STORE (DOUBLE):
+	CASE_BUILT_IN_TM_STORE (LDOUBLE):
+	CASE_BUILT_IN_TM_STORE (M64):
+	CASE_BUILT_IN_TM_STORE (M128):
+	CASE_BUILT_IN_TM_STORE (M256):
+	case BUILT_IN_TM_MEMCPY:
+	case BUILT_IN_TM_MEMMOVE:
+	  {
+	    ao_ref dref;
+	    tree size = NULL_TREE;
+	    /* Don't pass in size for strncat, as the maximum size
+	       is strlen (dest) + n + 1 instead of n, resp.
+	       n + 1 at dest + strlen (dest), but strlen (dest) isn't
+	       known.  */
+	    if (gimple_call_num_args (call) == 3
+		&& DECL_FUNCTION_CODE (callee) != BUILT_IN_STRNCAT)
+	      size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	case BUILT_IN_STRCPY_CHK:
+	case BUILT_IN_STRNCPY_CHK:
+	case BUILT_IN_MEMCPY_CHK:
+	case BUILT_IN_MEMMOVE_CHK:
+	case BUILT_IN_MEMPCPY_CHK:
+	case BUILT_IN_STPCPY_CHK:
+	case BUILT_IN_STPNCPY_CHK:
+	case BUILT_IN_STRCAT_CHK:
+	case BUILT_IN_STRNCAT_CHK:
+	case BUILT_IN_MEMSET_CHK:
+	  {
+	    ao_ref dref;
+	    tree size = NULL_TREE;
+	    /* Don't pass in size for __strncat_chk, as the maximum size
+	       is strlen (dest) + n + 1 instead of n, resp.
+	       n + 1 at dest + strlen (dest), but strlen (dest) isn't
+	       known.  */
+	    if (gimple_call_num_args (call) == 4
+		&& DECL_FUNCTION_CODE (callee) != BUILT_IN_STRNCAT_CHK)
+	      size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 0),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	case BUILT_IN_BCOPY:
+	  {
+	    ao_ref dref;
+	    tree size = gimple_call_arg (call, 2);
+	    ao_ref_init_from_ptr_and_size (&dref,
+					   gimple_call_arg (call, 1),
+					   size);
+	    return refs_may_alias_p_1 (&dref, ref, false);
+	  }
+	/* Allocating memory does not have any side-effects apart from
+	   being the definition point for the pointer.  */
+	case BUILT_IN_MALLOC:
+	case BUILT_IN_ALIGNED_ALLOC:
+	case BUILT_IN_CALLOC:
+	case BUILT_IN_STRDUP:
+	case BUILT_IN_STRNDUP:
+	  /* Unix98 specifies that errno is set on allocation failure.  */
+	  if (flag_errno_math
+	      && targetm.ref_may_alias_errno (ref))
+	    return true;
 	  return false;
-	}
-    }
+	case BUILT_IN_STACK_SAVE:
+	CASE_BUILT_IN_ALLOCA:
+	case BUILT_IN_ASSUME_ALIGNED:
+	  return false;
+	/* But posix_memalign stores a pointer into the memory pointed to
+	   by its first argument.  */
+	case BUILT_IN_POSIX_MEMALIGN:
+	  {
+	    tree ptrptr = gimple_call_arg (call, 0);
+	    ao_ref dref;
+	    ao_ref_init_from_ptr_and_size (&dref, ptrptr,
+					   TYPE_SIZE_UNIT (ptr_type_node));
+	    return (refs_may_alias_p_1 (&dref, ref, false)
+		    || (flag_errno_math
+			&& targetm.ref_may_alias_errno (ref)));
+	  }
+	/* Freeing memory kills the pointed-to memory.  More importantly
+	   the call has to serve as a barrier for moving loads and stores
+	   across it.  */
+	case BUILT_IN_FREE:
+	case BUILT_IN_VA_END:
+	  {
+	    tree ptr = gimple_call_arg (call, 0);
+	    return ptr_deref_may_alias_ref_p_1 (ptr, ref);
+	  }
+	/* Realloc serves both as allocation point and deallocation point.  */
+	case BUILT_IN_REALLOC:
+	  {
+	    tree ptr = gimple_call_arg (call, 0);
+	    /* Unix98 specifies that errno is set on allocation failure.  */
+	    return ((flag_errno_math
+		     && targetm.ref_may_alias_errno (ref))
+		    || ptr_deref_may_alias_ref_p_1 (ptr, ref));
+	  }
+	case BUILT_IN_GAMMA_R:
+	case BUILT_IN_GAMMAF_R:
+	case BUILT_IN_GAMMAL_R:
+	case BUILT_IN_LGAMMA_R:
+	case BUILT_IN_LGAMMAF_R:
+	case BUILT_IN_LGAMMAL_R:
+	  {
+	    tree out = gimple_call_arg (call, 1);
+	    if (ptr_deref_may_alias_ref_p_1 (out, ref))
+	      return true;
+	    if (flag_errno_math)
+	      break;
+	    return false;
+	  }
+	case BUILT_IN_FREXP:
+	case BUILT_IN_FREXPF:
+	case BUILT_IN_FREXPL:
+	case BUILT_IN_MODF:
+	case BUILT_IN_MODFF:
+	case BUILT_IN_MODFL:
+	  {
+	    tree out = gimple_call_arg (call, 1);
+	    return ptr_deref_may_alias_ref_p_1 (out, ref);
+	  }
+	case BUILT_IN_REMQUO:
+	case BUILT_IN_REMQUOF:
+	case BUILT_IN_REMQUOL:
+	  {
+	    tree out = gimple_call_arg (call, 2);
+	    if (ptr_deref_may_alias_ref_p_1 (out, ref))
+	      return true;
+	    if (flag_errno_math)
+	      break;
+	    return false;
+	  }
+	case BUILT_IN_SINCOS:
+	case BUILT_IN_SINCOSF:
+	case BUILT_IN_SINCOSL:
+	  {
+	    tree sin = gimple_call_arg (call, 1);
+	    tree cos = gimple_call_arg (call, 2);
+	    return (ptr_deref_may_alias_ref_p_1 (sin, ref)
+		    || ptr_deref_may_alias_ref_p_1 (cos, ref));
+	  }
+	/* __sync_* builtins and some OpenMP builtins act as threading
+	   barriers.  */
+#undef DEF_SYNC_BUILTIN
+#define DEF_SYNC_BUILTIN(ENUM, NAME, TYPE, ATTRS) case ENUM:
+#include "sync-builtins.def"
+#undef DEF_SYNC_BUILTIN
+	case BUILT_IN_GOMP_ATOMIC_START:
+	case BUILT_IN_GOMP_ATOMIC_END:
+	case BUILT_IN_GOMP_BARRIER:
+	case BUILT_IN_GOMP_BARRIER_CANCEL:
+	case BUILT_IN_GOMP_TASKWAIT:
+	case BUILT_IN_GOMP_TASKGROUP_END:
+	case BUILT_IN_GOMP_CRITICAL_START:
+	case BUILT_IN_GOMP_CRITICAL_END:
+	case BUILT_IN_GOMP_CRITICAL_NAME_START:
+	case BUILT_IN_GOMP_CRITICAL_NAME_END:
+	case BUILT_IN_GOMP_LOOP_END:
+	case BUILT_IN_GOMP_LOOP_END_CANCEL:
+	case BUILT_IN_GOMP_ORDERED_START:
+	case BUILT_IN_GOMP_ORDERED_END:
+	case BUILT_IN_GOMP_SECTIONS_END:
+	case BUILT_IN_GOMP_SECTIONS_END_CANCEL:
+	case BUILT_IN_GOMP_SINGLE_COPY_START:
+	case BUILT_IN_GOMP_SINGLE_COPY_END:
+	  return true;
+	default:
+	  /* Fallthru to general call handling.  */;
+      }
 
   /* Check if base is a global static variable that is not written
      by the function.  */
diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
index eecb8da6dd7..1dd02c0ea62 100644
--- a/gcc/tree-ssa-alias.h
+++ b/gcc/tree-ssa-alias.h
@@ -108,33 +108,6 @@ ao_ref::max_size_known_p () const
   return known_size_p (max_size);
 }
 
-/* Flags used in ao_function_info.  */
-
-enum ao_function_flags
-{
-  AO_FUNCTION_BARRIER = 1,
-  AO_FUNCTION_ERRNO = 2,
-};
-
-/* Describe side effects relevant for alias analysis of function call to
-   DECL.  */
-
-struct ao_function_info
-{
-  int num_param_reads;  /* Number of parameters function reads from,
-			   -1 if reads are unknown.  */
-  struct ao_access_info
-    {
-      char param; 	/* Index of parameter read/written from.  */
-      char size_param;	/* Index of parameter specifying size of the access,
-			   -1 if unknown.  */
-      char size;	/* Size of access if known, 0 if unknown.  */
-    } reads[2];
-  int num_param_writes;
-  struct ao_access_info writes[2];
-  enum ao_function_flags flags;
-};
-
 /* In tree-ssa-alias.c  */
 extern void ao_ref_init (ao_ref *, tree);
 extern void ao_ref_init_from_ptr_and_size (ao_ref *, tree, tree);
@@ -185,7 +158,6 @@ extern void debug (pt_solution *ptr);
 extern void dump_points_to_info_for (FILE *, tree);
 extern void debug_points_to_info_for (tree);
 extern void dump_alias_stats (FILE *);
-extern bool ao_classify_builtin (tree callee, ao_function_info *info);
 
 
 /* In tree-ssa-structalias.c  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-10 19:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 19:49 [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Revert "Handle builtins" Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).