aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-object-size.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-object-size.cc')
-rw-r--r--gcc/tree-object-size.cc55
1 files changed, 17 insertions, 38 deletions
diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
index a551f2b..8545eff 100644
--- a/gcc/tree-object-size.cc
+++ b/gcc/tree-object-size.cc
@@ -851,21 +851,17 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
/* Compute __builtin_object_size for a CALL to .ACCESS_WITH_SIZE,
OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
- The 2nd, 3rd, and the 4th parameters of the call determine the size of
+
+ The 2nd, 3rd, and 4th parameters of the call determine the size of
the CALL:
2nd argument REF_TO_SIZE: The reference to the size of the object,
- 3rd argument CLASS_OF_SIZE: The size referenced by the REF_TO_SIZE represents
- 0: the number of bytes;
- 1: the number of the elements of the object type;
- 4th argument TYPE_OF_SIZE: A constant 0 with its TYPE being the same as the TYPE
- of the object referenced by REF_TO_SIZE
- 6th argument: A constant 0 with the pointer TYPE to the original flexible
- array type or pointer field type.
-
- The size of the element can be retrived from the TYPE of the 6th argument
- of the call, which is the pointer to the original flexible array type or
- the type of the original pointer field. */
+ 3rd argument TYPE_OF_SIZE + ACCESS_MODE: An integer constant with a pointer
+ TYPE.
+ The pointee TYPE of this pointer TYPE is the TYPE of the object referenced
+ by REF_TO_SIZE.
+
+ 4th argument: The TYPE_SIZE_UNIT of the element TYPE of the array. */
static tree
access_with_size_object_size (const gcall *call, int object_size_type)
@@ -873,17 +869,14 @@ access_with_size_object_size (const gcall *call, int object_size_type)
/* If not for dynamic object size, return. */
if ((object_size_type & OST_DYNAMIC) == 0)
return size_unknown (object_size_type);
-
gcc_assert (gimple_call_internal_p (call, IFN_ACCESS_WITH_SIZE));
- /* The type of the 6th argument type is the pointer TYPE to the original
- flexible array type or to the original pointer type. */
- tree pointer_to_array_type = TREE_TYPE (gimple_call_arg (call, 5));
- gcc_assert (POINTER_TYPE_P (pointer_to_array_type));
- tree element_type = TREE_TYPE (TREE_TYPE (pointer_to_array_type));
- tree element_size = TYPE_SIZE_UNIT (element_type);
+
tree ref_to_size = gimple_call_arg (call, 1);
- unsigned int class_of_size = TREE_INT_CST_LOW (gimple_call_arg (call, 2));
- tree type = TREE_TYPE (gimple_call_arg (call, 3));
+ tree type = TREE_TYPE (TREE_TYPE (gimple_call_arg (call, 2)));
+
+ /* The 4th argument is the TYPE_SIZE_UNIT for the element of the original
+ flexible array. */
+ tree element_size = gimple_call_arg (call, 3);
tree size = fold_build2 (MEM_REF, type, ref_to_size,
build_int_cst (ptr_type_node, 0));
@@ -897,12 +890,9 @@ access_with_size_object_size (const gcall *call, int object_size_type)
build_zero_cst (type), size);
}
- if (class_of_size == 1)
- size = size_binop (MULT_EXPR,
- fold_convert (sizetype, size),
- fold_convert (sizetype, element_size));
- else
- size = fold_convert (sizetype, size);
+ size = size_binop (MULT_EXPR,
+ fold_convert (sizetype, size),
+ fold_convert (sizetype, element_size));
if (!todo)
todo = TODO_update_ssa_only_virtuals;
@@ -1944,17 +1934,6 @@ collect_object_sizes_for (struct object_size_info *osi, tree var)
if (TREE_CODE (rhs) == SSA_NAME
&& POINTER_TYPE_P (TREE_TYPE (rhs)))
reexamine = merge_object_sizes (osi, var, rhs);
- /* Handle the following stmt #2 to propagate the size from the
- stmt #1 to #3:
- 1 _1 = .ACCESS_WITH_SIZE (_3, _4, 1, 0, -1, 0B);
- 2 _5 = *_1;
- 3 _6 = __builtin_dynamic_object_size (_5, 1);
- */
- else if (TREE_CODE (rhs) == MEM_REF
- && POINTER_TYPE_P (TREE_TYPE (rhs))
- && TREE_CODE (TREE_OPERAND (rhs, 0)) == SSA_NAME
- && integer_zerop (TREE_OPERAND (rhs, 1)))
- reexamine = merge_object_sizes (osi, var, TREE_OPERAND (rhs, 0));
else
expr_object_size (osi, var, rhs);
}