https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503
qinzhao at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qinzhao at gcc dot gnu.org
--- Comment #10 from qinzhao at gcc dot gnu.org ---
(In reply to Martin Uecker from comment #7)
> > We would need
> > to emit the builtin in the caller as well as callee of the function that has
> > the access attribute while for alloc_size, we only need to emit this in the
> > caller.
>
> Yes, makes sense, although I guess caller part for "access"
> is only for warning and not relevant for BDOS, so couldĀ
> potentially stay as it is for now.
I am now working on this bug. the first major question is:
for the simple case in the PR:
__attribute__ ((alloc_size (1))) int* f1 (int n) { return f (n); }
void h1 (void)
{
int *p = f1 (3);
__builtin_memset (p, 0, 3 * sizeof p); // missing warning
}
where in the IR we should insert the call to the internal function
.ACCESS_WITH_SIZE (REF, COUNTED_BY_REF, (* TYPE_OF_SIZE)0, TYPE_SIZE_UNIT for
element)?
My basic idea is: when the call to a routine marked with "alloc_size"
attribute, generate a call to .ACCESS_WITH_SIZE for its assigned returned
pointer.
i.e, in the above example, when we see
p = f1 (3)
we will wrap the pointer "p" with .ACCESS_WITH_SIZE (p, 3, 0, 1), i.e,
.ACCESS_WITH_SIZE (p, 3, 0, 1) = f1 (3);
is this reasonable?