[llvm-commits] [llvm] r89421 - /llvm/trunk/lib/Analysis/CaptureTracking.cpp
Duncan Sands
baldrick at free.fr
Fri Nov 20 03:53:11 PST 2009
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:
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.
More information about the llvm-commits
mailing list