Hi, Joseph and Martin:

I am now working on PR96503 (attribute alloc_size effect lost after inlining)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503

My first major questions are:

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
}

1. where in the IR we should insert the call to the internal function 
.ACCESS_WITH_SIZE?

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?

2. If the above idea is reasonable, where should I implement this in C FE?

What’s in my mind is: where a function returned value is assigned to a pointer,
 checking whether the function type has “alloc_size” attribute, if so, wrapping
The pointer that the function assigned to to a call to .ACCESS_WITH_SIZE.

Which parts of the code, or which routines in C FE I should focus on?

Let me know if you have any comments and suggestions. 

Thanks a lot for your help.

Reply via email to