[llvm-branch-commits] [llvm-branch] r89436 - /llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp
Dan Gohman
gohman at apple.com
Thu Nov 19 17:48:19 PST 2009
Author: djg
Date: Thu Nov 19 19:48:18 2009
New Revision: 89436
URL: http://llvm.org/viewvc/llvm-project?rev=89436&view=rev
Log:
$ svn merge -c 89411 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89411 into '.':
U lib/Analysis/CaptureTracking.cpp
$ svn merge -c 89419 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89419 into '.':
G lib/Analysis/CaptureTracking.cpp
$ svn merge -c 89421 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89421 into '.':
G lib/Analysis/CaptureTracking.cpp
$ svn merge -c 89434 https://djg@llvm.org/svn/llvm-project/llvm/trunk
--- Merging r89434 into '.':
G lib/Analysis/CaptureTracking.cpp
Modified:
llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp
Modified: llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp?rev=89436&r1=89435&r2=89436&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Analysis/CaptureTracking.cpp Thu Nov 19 19:48:18 2009
@@ -19,6 +19,7 @@
#include "llvm/Analysis/CaptureTracking.h"
#include "llvm/Instructions.h"
#include "llvm/Value.h"
+#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/CallSite.h"
@@ -56,8 +57,7 @@
// Not captured if the callee is readonly, doesn't return a copy through
// its return value and doesn't unwind (a readonly function can leak bits
// by throwing an exception or not depending on the input value).
- if (CS.onlyReadsMemory() && CS.doesNotThrow() &&
- I->getType() == Type::getVoidTy(V->getContext()))
+ if (CS.onlyReadsMemory() && CS.doesNotThrow() && I->getType()->isVoidTy())
break;
// Not captured if only passed via 'nocapture' arguments. Note that
@@ -106,9 +106,21 @@
}
break;
case Instruction::ICmp:
- // Comparing the pointer against null does not count as a capture.
- if (isa<ConstantPointerNull>(I->getOperand(1)))
+ // 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;
+ // Don't count comparisons of two pointers within the same object
+ // as captures.
+ if (I->getOperand(0)->getUnderlyingObject() ==
+ I->getOperand(1)->getUnderlyingObject())
break;
+ // Otherwise, be conservative. There are crazy ways to capture pointers
+ // using comparisons.
return true;
default:
// Something else - be conservative and say it is captured.
More information about the llvm-branch-commits
mailing list