summaryrefslogtreecommitdiff
path: root/lib/Analysis/CaptureTracking.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-11-20 17:50:21 +0000
committerDan Gohman <gohman@apple.com>2009-11-20 17:50:21 +0000
commit837be07979723fb05ef47c828da014ce9ed1ba34 (patch)
treea58deed4bde8b6659254782e8f57545b5e37384e /lib/Analysis/CaptureTracking.cpp
parent37628e009827420d56cdf9b26c5104abd726e53b (diff)
downloadllvm-837be07979723fb05ef47c828da014ce9ed1ba34.tar.gz
llvm-837be07979723fb05ef47c828da014ce9ed1ba34.tar.bz2
llvm-837be07979723fb05ef47c828da014ce9ed1ba34.tar.xz
Revert the rule that considers comparisons between two pointers in the
same object to be a non-capture; Duncan pointed out a way that such a comparison could be a capture. Make the rule that considers a comparison against null more specific, and only consider noalias return values compared against null. This still supports test/Transforms/GVN/nonescaping-malloc.ll, and is not susceptible to the problem Duncan pointed out with noalias arguments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89468 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CaptureTracking.cpp')
-rw-r--r--lib/Analysis/CaptureTracking.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp
index 1db9f2dda1..8364d81497 100644
--- a/lib/Analysis/CaptureTracking.cpp
+++ b/lib/Analysis/CaptureTracking.cpp
@@ -106,19 +106,14 @@ bool llvm::PointerMayBeCaptured(const Value *V,
}
break;
case Instruction::ICmp:
- // 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))
+ // Don't count comparisons of a no-alias return value against null as
+ // captures. This allows us to ignore comparisons of malloc results
+ // with null, for example.
+ if (isNoAliasCall(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;