[LLVMdev] alloc_size metadata
Nuno Lopes
nunoplopes at sapo.pt
Tue May 29 18:57:40 PDT 2012
>> About Duncan's comment about having the memory builtin analysis
>> recognize this intrinsic, well I agree it should (and I'll take care
>> of that), but I'm not sure if we should be very aggressive in
>> optimizing based on this metadata.
>> For example, do we really want to remove a call to a custom
>> allocator whose return value is unused (like we do for malloc)? If
>> so, we'll also need a metadata node to mark de-allocation functions
>> (so that sequences like my_free(my_malloc(xx)) are removed).
>
> You might want to restrict that to custom allocators that have an
> additional 'removable' attribute.
>
> Out of curiosity, does any of this potentially effect the presence or
> absence of 'inbounds' on GEP instructions?
No, I don't think so. The inbounds flag means that the offset computation
will not overflow. Here we are only discussing the discovery of the object
size (potentially pointed by a GEP). As Duncan pointed out, knowing an
object's size may be used to expose more undefined behavior to optimizers if
we prove that the index will fall out of bounds.
Nuno
More information about the llvm-dev
mailing list