[llvm-commits] [llvm] r89421 - /llvm/trunk/lib/Analysis/CaptureTracking.cpp
Chris Lattner
clattner at apple.com
Sat Nov 21 07:21:49 PST 2009
On Nov 20, 2009, at 3:53 AM, Duncan Sands wrote:
> Hi Dan,
>
>> + // Don't count comparisons of the original value against null as captures.
>> + // This allows us to ignore comparisons of malloc results with null,
>> + // for example.
>> + if (isIdentifiedObject(V))
>> + if (ConstantPointerNull *CPN =
>> + dyn_cast<ConstantPointerNull>(I->getOperand(1)))
>> + if (CPN->getType()->getAddressSpace() == 0)
>> + break;
>
> I think this is wrong, consider the following pseudocode example:
While this example is "possible" I really don't think this is worth worrying about. It is not valid C code, is not likely to exist in practice, etc. Beyond that, comparison against null is really common and we really do want "nocapture" in this cases.
-Chris
>
> i1 equals_null (i8* %P noalias) {
> return %P == 0
> }
>
> Thanks to your change, this function will be marked nocapture, because
> a noalias parameter counts as an identified object.
>
> Now consider
>
> i8* @capture (i8* %P noalias) {
> n = 0
> loop:
> %Q = GEP %P, -n
> if (equals_null(%Q))
> break;
> n = n + 1;
> goto loop;
> return GEP null, n
> }
>
> I think it is correct to pass %Q to equals_null given that %P is noalias.
> So this example shows that %P can be captured even though CaptureTracking
> says it is not with your change. A variant of this is to have %P be some
> noalias value like the return value of malloc.
>
> Ciao,
>
> Duncan.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list