[llvm-commits] [llvm] r89389 - /llvm/trunk/lib/Analysis/CaptureTracking.cpp

Duncan Sands baldrick at free.fr
Fri Nov 20 00:03:05 PST 2009


Hi Dan,

> Comparing a pointer with null is not a capture.

this is wrong, given our current definition of capture (which is extremely
conservative, and not defined in terms of pointer aliasing rules):
any method which allows you to end up with a new pointer that holds the
contents of the original pointer is capture, even if this involves chopping
the original pointer into bits and reassembling them somewhere else.

I think the C language standard says that in this case, you are allowed to
assume that the new pointer does not alias the original pointer, but it was
decided (i.e. Chris decreed) to use the language independent definition "no
bits escape". Proviso: when determining if some bits of a pointer may be
captured, you are allowed to assume that no bits of it were already captured.

So how does comparison with null allow you to capture a pointer P?  Easy!
   n = 0
   loop:
     Q = GEP P, -n
     if (Q == null)
       break;
     n = n + 1;
     goto loop;
   captured_value = GEP null, n

Ciao,

Duncan.



More information about the llvm-commits mailing list