[LLVMdev] alloc_size metadata

Chandler Carruth chandlerc at google.com
Fri May 25 00:22:24 PDT 2012


On Fri, May 25, 2012 at 12:03 AM, Kostya Serebryany <kcc at google.com> wrote:

>
>
> On Thu, May 24, 2012 at 7:43 PM, John Criswell <criswell at illinois.edu>wrote:
>
>> On 5/24/12 3:51 AM, Duncan Sands wrote:
>> > Hi Nuno,
>> >
>> >> I'm implementing the alloc_size function attribute in clang.
>> > does anyone actually use this attribute?  And if they do, can it really
>> buy
>> > them anything?  How about "implementing" it by ignoring it!
>>
>> Tools like ASan and SAFECode *could* use this attribute
>
>
> A case where this may be useful for asan:
>    size_t n, m; ...
>    int *x = new int [n]; ...
>    x[m]  // here we can check "m < n" instead of a more expensive shadow
> memory lookup.
> For asan such optimization is possible only if 'x' does not escape the
> current function before the use,
> otherwise we may lose a use-after-free.
>
> I don't know whether such optimization will fire often enough to pay the
> price for the added complexity of the implementation.
> It would be interesting to see statistics on some huge app.
>

I think this is key -- there should be some clear numbers and evidence that
this is a really important semantic extension in order to get accurate and
efficient results.

And as Duncan points out, we should be confident that there is no existing
mechanism to get the same optimization improvements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120525/aa3a3fbc/attachment.html>


More information about the llvm-dev mailing list