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.

> 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);

(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

Reply via email to