built in memset
John Carr
jfc@mit.edu
Tue Apr 21 23:21:00 GMT 1998
My alias changes revealed a bug in setting MEM_IN_STRUCT_P when
calling builtin memset. This patch improves the situation but there
are still potential bugs. memcpy probably also needs to be fixed.
I think it would be correct to always set MEM_IN_STRUCT_P, or always
set it except in cases where the argument is the address of a scalar
(i.e. &foo but not ptr = &foo; memset(ptr).)
The specific bug was compiling cse.c:simplify_plus_or_minus:
rtx ops[8];
bzero ((char *) ops, sizeof ops);
After removing casts, ops is a pointer to a pointer, not a pointer to
a structure. That is all the existing code checks: is the type a
pointer to aggregate.
Tue Apr 21 20:36:28 1998 John Carr <jfc@mit.edu>
* expr.c (expand_builtin, case MEMSET): Set MEM_IN_STRUCT_P
if the argument is the adress of a structure or array.
*** expr.c 1998/04/16 23:56:03 1.48
--- expr.c 1998/04/22 00:36:51
*************** expand_builtin (exp, target, subtarget,
*** 8634,8640 ****
/* There could be a void* cast on top of the object. */
while (TREE_CODE (dest) == NOP_EXPR)
dest = TREE_OPERAND (dest, 0);
! type = TREE_TYPE (TREE_TYPE (dest));
MEM_IN_STRUCT_P (dest_mem) = AGGREGATE_TYPE_P (type);
dest_addr = clear_storage (dest_mem, len_rtx, dest_align);
--- 8634,8646 ----
/* There could be a void* cast on top of the object. */
while (TREE_CODE (dest) == NOP_EXPR)
dest = TREE_OPERAND (dest, 0);
!
! if (TREE_CODE (dest) == ADDR_EXPR)
! /* If this is the address of an object, check whether the
! object is an array. */
! type = TREE_TYPE (TREE_OPERAND (dest, 0));
! else
! type = TREE_TYPE (TREE_TYPE (dest));
MEM_IN_STRUCT_P (dest_mem) = AGGREGATE_TYPE_P (type);
dest_addr = clear_storage (dest_mem, len_rtx, dest_align);
More information about the Gcc
mailing list