On Thu, Nov 1, 2012 at 12:16 PM, Jakub Jelinek <[email protected]> wrote:
> On Thu, Nov 01, 2012 at 11:57:21AM -0700, Xinliang David Li wrote:
>> That is exactly related to tsan -- it should skip local variable that
>> is not address taken (though still addressable, which by addressable,
>> it means the variable has a memory home).
>>
>> The problem is that if 'addressable' bit is not equivalent to 'address
>> taken', it will be too conservative to use it --- as addressable
>> variables may not be address taken.
>
> But TREE_ADDRESSABLE is equivalent to address taken.
It seems not -- unless our definition of them is different. I debugged
the following program:
int foo()
{
int a[1000];
int i, s;
for (i = 0; i < 1000; i++)
a[i] = i;
for (i = 0; i < 1000; i++)
s += a[i];
return s;
}
a's address is not taken (at source level), but it is marked as addressable.
>
>> Note that even 'address taken' is too conservative to use here. Only
>> when it is escaped the thread (via non TLS global pointers or other
>> escaped local, heap memories), should it be considered to be
>> instrumented.
>
> If you need it even less conservative, I guess you could do say:
> struct ptr_info_def pi;
> memset (&pi, 0, sizeof (pi));
> pi.escaped = 1;
> pi.nonlocal = 1;
> return pt_solution_includes (&pi, decl);
>
That will be nice. Are points-to info exposed to client code like
this? Are there standard aliaser interfaces for them?
thanks,
David
> (the nonlocal in pt_solution_includes_1 performs the is_global_var check
> that needs to be done, and escaped checks whether decl is in the escaped
> set).
>
> Then say for
> int foo(int i)
> {
> int a[100], b[100], c[100], d[100], *p;
> if (i < 10)
> p = a;
> else if (i < 60)
> p = b;
> else if (i <= 65)
> p = c;
> else
> p = d;
> p[i] = 1;
> p[2 * i] = 2;
> return p[i + 1];
> }
> still none of a, b, c, and d vars will be included, even when they are
> TREE_ADDRESSABLE, but if you say pass p to another function, or set a global
> var to it, it will already return true for them.
>
> Jakub