diff mbox series

tree-object-size: Drop unused pdecl and poff arguments

Message ID 20211007141504.598078-1-siddhesh@gotplt.org
State New
Headers show
Series tree-object-size: Drop unused pdecl and poff arguments | expand

Commit Message

Siddhesh Poyarekar Oct. 7, 2021, 2:15 p.m. UTC
The pdecl and poff arguments were added to allow their use in
compute_objsize in builtins.c.  That use has been gone for a while now
since compute_objsize does its own size estimation, so drop these
arguments to simplify code.

gcc/ChangeLog:

	* tree-object-size.c (addr_object_size,
	compute_builtin_object_size): Drop PDECL and POFF arguments.
	(addr_object_size): Adjust calls.
	* tree-object-size.h (compute_builtin_object_size): Drop PDECL
	and POFF arguments.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
---
 gcc/tree-object-size.c | 42 +++++++-----------------------------------
 gcc/tree-object-size.h |  3 +--
 2 files changed, 8 insertions(+), 37 deletions(-)

Comments

Jakub Jelinek Oct. 7, 2021, 2:25 p.m. UTC | #1
On Thu, Oct 07, 2021 at 07:45:04PM +0530, Siddhesh Poyarekar wrote:
> The pdecl and poff arguments were added to allow their use in
> compute_objsize in builtins.c.  That use has been gone for a while now
> since compute_objsize does its own size estimation, so drop these

Since r11-1517-g5acc654e380797bbf402bc3a0a67f9a6ac4c2a83 indeed.

> arguments to simplify code.
> 
> gcc/ChangeLog:
> 
> 	* tree-object-size.c (addr_object_size,
> 	compute_builtin_object_size): Drop PDECL and POFF arguments.
> 	(addr_object_size): Adjust calls.
> 	* tree-object-size.h (compute_builtin_object_size): Drop PDECL
> 	and POFF arguments.

Ok, thanks.

> 
> Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>

	Jakub
diff mbox series

Patch

diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 744748d4d9b..6a4dc724f34 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -54,8 +54,7 @@  static const unsigned HOST_WIDE_INT unknown[4] = {
 
 static tree compute_object_offset (const_tree, const_tree);
 static bool addr_object_size (struct object_size_info *,
-			      const_tree, int, unsigned HOST_WIDE_INT *,
-			      tree * = NULL, tree * = NULL);
+			      const_tree, int, unsigned HOST_WIDE_INT *);
 static unsigned HOST_WIDE_INT alloc_object_size (const gcall *, int);
 static tree pass_through_call (const gcall *);
 static void collect_object_sizes_for (struct object_size_info *, tree);
@@ -209,17 +208,10 @@  decl_init_size (tree decl, bool min)
 
 static bool
 addr_object_size (struct object_size_info *osi, const_tree ptr,
-		  int object_size_type, unsigned HOST_WIDE_INT *psize,
-		  tree *pdecl /* = NULL */, tree *poff /* = NULL */)
+		  int object_size_type, unsigned HOST_WIDE_INT *psize)
 {
   tree pt_var, pt_var_size = NULL_TREE, var_size, bytes;
 
-  tree dummy_decl, dummy_off = size_zero_node;
-  if (!pdecl)
-    pdecl = &dummy_decl;
-  if (!poff)
-    poff = &dummy_off;
-
   gcc_assert (TREE_CODE (ptr) == ADDR_EXPR);
 
   /* Set to unknown and overwrite just before returning if the size
@@ -241,7 +233,7 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
 	  || TREE_CODE (TREE_OPERAND (pt_var, 0)) != SSA_NAME)
 	{
 	  compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
-				       object_size_type & ~1, &sz, pdecl, poff);
+				       object_size_type & ~1, &sz);
 	}
       else
 	{
@@ -259,11 +251,6 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
 	  offset_int mem_offset;
 	  if (mem_ref_offset (pt_var).is_constant (&mem_offset))
 	    {
-	      if (*poff)
-		*poff = wide_int_to_tree (ptrdiff_type_node,
-					  mem_offset + wi::to_offset (*poff));
-	      else
-		*poff = wide_int_to_tree (ptrdiff_type_node, mem_offset);
 	      offset_int dsz = wi::sub (sz, mem_offset);
 	      if (wi::neg_p (dsz))
 		sz = 0;
@@ -281,7 +268,6 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
     }
   else if (DECL_P (pt_var))
     {
-      *pdecl = pt_var;
       pt_var_size = decl_init_size (pt_var, object_size_type & 2);
       if (!pt_var_size)
 	return false;
@@ -418,7 +404,6 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
       bytes = compute_object_offset (TREE_OPERAND (ptr, 0), var);
       if (bytes != error_mark_node)
 	{
-	  *poff = bytes;
 	  if (TREE_CODE (bytes) == INTEGER_CST
 	      && tree_int_cst_lt (var_size, bytes))
 	    bytes = size_zero_node;
@@ -438,7 +423,6 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
 		bytes2 = size_zero_node;
 	      else
 		bytes2 = size_binop (MINUS_EXPR, pt_var_size, bytes2);
-	      *poff = size_binop (PLUS_EXPR, *poff, bytes2);
 	      bytes = size_binop (MIN_EXPR, bytes, bytes2);
 	    }
 	}
@@ -446,11 +430,7 @@  addr_object_size (struct object_size_info *osi, const_tree ptr,
   else if (!pt_var_size)
     return false;
   else
-    {
-      bytes = pt_var_size;
-      if (!*poff)
-	*poff = size_zero_node;
-    }
+    bytes = pt_var_size;
 
   if (tree_fits_uhwi_p (bytes))
     {
@@ -548,17 +528,10 @@  pass_through_call (const gcall *call)
 
 bool
 compute_builtin_object_size (tree ptr, int object_size_type,
-			     unsigned HOST_WIDE_INT *psize,
-			     tree *pdecl /* = NULL */, tree *poff /* = NULL */)
+			     unsigned HOST_WIDE_INT *psize)
 {
   gcc_assert (object_size_type >= 0 && object_size_type <= 3);
 
-  tree dummy_decl, dummy_off = size_zero_node;
-  if (!pdecl)
-    pdecl = &dummy_decl;
-  if (!poff)
-    poff = &dummy_off;
-
   /* Set to unknown and overwrite just before returning if the size
      could be determined.  */
   *psize = unknown[object_size_type];
@@ -567,7 +540,7 @@  compute_builtin_object_size (tree ptr, int object_size_type,
     init_offset_limit ();
 
   if (TREE_CODE (ptr) == ADDR_EXPR)
-    return addr_object_size (NULL, ptr, object_size_type, psize, pdecl, poff);
+    return addr_object_size (NULL, ptr, object_size_type, psize);
 
   if (TREE_CODE (ptr) != SSA_NAME
       || !POINTER_TYPE_P (TREE_TYPE (ptr)))
@@ -592,12 +565,11 @@  compute_builtin_object_size (tree ptr, int object_size_type,
 
 	      if (tree_fits_shwi_p (offset)
 		  && compute_builtin_object_size (ptr, object_size_type,
-						  psize, pdecl, poff))
+						  psize))
 		{
 		  /* Return zero when the offset is out of bounds.  */
 		  unsigned HOST_WIDE_INT off = tree_to_shwi (offset);
 		  *psize = off < *psize ? *psize - off : 0;
-		  *poff = offset;
 		  return true;
 		}
 	    }
diff --git a/gcc/tree-object-size.h b/gcc/tree-object-size.h
index 358b902e7db..ef18aea50db 100644
--- a/gcc/tree-object-size.h
+++ b/gcc/tree-object-size.h
@@ -22,8 +22,7 @@  along with GCC; see the file COPYING3.  If not see
 
 extern void init_object_sizes (void);
 extern void fini_object_sizes (void);
-extern bool compute_builtin_object_size (tree, int, unsigned HOST_WIDE_INT *,
-					 tree * = NULL, tree * = NULL);
+extern bool compute_builtin_object_size (tree, int, unsigned HOST_WIDE_INT *);
 extern tree decl_init_size (tree, bool);
 
 #endif  // GCC_TREE_OBJECT_SIZE_H