[llvm-commits] [PATCH] Try to figure out <size> argument in llvm.lifetime intrinsics

Kostya Serebryany kcc at google.com
Sun Nov 11 16:01:17 PST 2012


On Sun, Nov 11, 2012 at 10:17 AM, Alexey Samsonov <samsonov at google.com>wrote:

>
>
> On Sun, Nov 11, 2012 at 10:10 PM, Dmitri Gribenko <gribozavr at gmail.com>wrote:
>
>> On Sun, Nov 11, 2012 at 7:32 PM, Dmitry N. Mikushin <maemarcus at gmail.com>
>> wrote:
>> > In case of stack reuse there should be another llvm.livetime start/end
>> > region, isn't it?
>>
>> I was thinking about something like this:
>>
>> $ cat a.c
>> #include <stdio.h>
>>
>> void store_ptr(int *);
>> int *load_ptr(void);
>> int ret_int(void);
>> void use_ptr(int *);
>> extern int global;
>>
>> int main()
>> {
>>   {
>>     int i[8];
>>     store_ptr(i);
>>   }
>>   {
>>     int j[8];
>>     j[0] = ret_int();
>>     use_ptr(j);
>>     int *k = load_ptr();
>>     *k = 42;
>>     use_ptr(j);
>>     printf("%d\n", global);
>>   }
>> }
>>
>> $ cat b.c
>> static int *ptr;
>>
>> void store_ptr(int *p) { ptr = p; }
>> int *load_ptr(void) { return ptr; }
>> int ret_int() { return 7; }
>> int global;
>> void use_ptr(int *p) { global = *p; }
>>
>> Currently ASan does not catch an issue in this code, but with lifetime
>> markers emitted by Clang, it should.
>>
>> Here 'i' and 'j' would occupy different addresses without stack reuse.
>>  In this case, 'i' would be still allocated while 'j' is alive, but
>> 'i' would be poisoned.  With stack reuse, 'i' and 'j' will most likely
>> occupy the same block of memory.
>>
>
> I see. But we can explicitly turn off stack reuse optimization in ASan
> mode.
>

Last time we discussed it, the resolution was that the stack reuse
optimization
is going to work in codegen, i.e. after ASan.
Since ASan merges all Allocas into one, this will effectively disable the
stack reuse optimization,
but nothing special needs to be done.
If stack reuse is done before ASan, yes, we would need to disable it.

--kcc



>
>
>>
>> Dmitri
>>
>> --
>> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
>> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
>>
>
>
>
> --
> Alexey Samsonov, MSK
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121111/b2a2e157/attachment.html>


More information about the llvm-commits mailing list