aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-07-07 14:27:09 +0000
committerDan Gohman <gohman@apple.com>2010-07-07 14:27:09 +0000
commit9e86f4364b912ae743490ba01d6989acfd12c046 (patch)
tree0eb6677f25fb104f50e85918f79d60b5665e0315 /lib/Analysis/BasicAliasAnalysis.cpp
parent46151f1764ec61bfe3724e5db41e7675a9d90a96 (diff)
Remove interprocedural-basic-aa and associated code. The AliasAnalysis
interface needs implementations to be consistent, so any code which wants to support different semantics must use a different interface. It's not currently worthwhile to add a new interface for this new concept. Document that AliasAnalysis doesn't support cross-function queries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp91
1 files changed, 14 insertions, 77 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 2f99c2e6b6..d3a67a8eba 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -194,6 +194,7 @@ ImmutablePass *llvm::createNoAAPass() { return new NoAA(); }
// BasicAliasAnalysis Pass
//===----------------------------------------------------------------------===//
+#ifndef NDEBUG
static const Function *getParent(const Value *V) {
if (const Instruction *inst = dyn_cast<Instruction>(V))
return inst->getParent()->getParent();
@@ -204,15 +205,6 @@ static const Function *getParent(const Value *V) {
return NULL;
}
-static bool sameParent(const Value *O1, const Value *O2) {
-
- const Function *F1 = getParent(O1);
- const Function *F2 = getParent(O2);
-
- return F1 && F1 == F2;
-}
-
-#ifdef XDEBUG
static bool notDifferentParent(const Value *O1, const Value *O2) {
const Function *F1 = getParent(O1);
@@ -227,25 +219,14 @@ namespace {
/// Because it doesn't chain to a previous alias analysis (like -no-aa), it
/// derives from the NoAA class.
struct BasicAliasAnalysis : public NoAA {
- /// Interprocedural - Flag for "interprocedural" mode, where we must
- /// support queries of values which live in different functions.
- bool Interprocedural;
-
static char ID; // Class identification, replacement for typeinfo
- BasicAliasAnalysis()
- : NoAA(&ID), Interprocedural(false) {}
- BasicAliasAnalysis(void *PID, bool interprocedural)
- : NoAA(PID), Interprocedural(interprocedural) {}
+ BasicAliasAnalysis() : NoAA(&ID) {}
AliasResult alias(const Value *V1, unsigned V1Size,
const Value *V2, unsigned V2Size) {
assert(Visited.empty() && "Visited must be cleared after use!");
-#ifdef XDEBUG
- assert((Interprocedural || notDifferentParent(V1, V2)) &&
- "BasicAliasAnalysis (-basicaa) doesn't support interprocedural "
- "queries; use InterproceduralAliasAnalysis "
- "(-interprocedural-basic-aa) instead.");
-#endif
+ assert(notDifferentParent(V1, V2) &&
+ "BasicAliasAnalysis doesn't support interprocedural queries.");
AliasResult Alias = aliasCheck(V1, V1Size, V2, V2Size);
Visited.clear();
return Alias;
@@ -324,6 +305,9 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) {
/// simple "address taken" analysis on local objects.
AliasAnalysis::ModRefResult
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
+ assert(notDifferentParent(CS.getInstruction(), P) &&
+ "AliasAnalysis query involving multiple functions!");
+
const Value *Object = P->getUnderlyingObject();
// If this is a tail call and P points to a stack location, we know that
@@ -336,16 +320,10 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
if (CI->isTailCall())
return NoModRef;
- // If we can identify an object and it's known to be within the
- // same function as the call, we can ignore interprocedural concerns.
- bool EffectivelyInterprocedural =
- Interprocedural && !sameParent(Object, CS.getInstruction());
-
// If the pointer is to a locally allocated object that does not escape,
// then the call can not mod/ref the pointer unless the call takes the pointer
// as an argument, and itself doesn't capture it.
if (!isa<Constant>(Object) && CS.getInstruction() != Object &&
- !EffectivelyInterprocedural &&
isNonEscapingLocalObject(Object)) {
bool PassedAsArg = false;
unsigned ArgNo = 0;
@@ -765,36 +743,25 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
if (CPN->getType()->getAddressSpace() == 0)
return NoAlias;
- // If we can identify two objects and they're known to be within the
- // same function, we can ignore interprocedural concerns.
- bool EffectivelyInterprocedural =
- Interprocedural && !sameParent(O1, O2);
-
if (O1 != O2) {
// If V1/V2 point to two different objects we know that we have no alias.
- if (isIdentifiedObject(O1, EffectivelyInterprocedural) &&
- isIdentifiedObject(O2, EffectivelyInterprocedural))
+ if (isIdentifiedObject(O1) && isIdentifiedObject(O2))
return NoAlias;
// Constant pointers can't alias with non-const isIdentifiedObject objects.
- if ((isa<Constant>(O1) &&
- isIdentifiedObject(O2, EffectivelyInterprocedural) &&
- !isa<Constant>(O2)) ||
- (isa<Constant>(O2) &&
- isIdentifiedObject(O1, EffectivelyInterprocedural) &&
- !isa<Constant>(O1)))
+ if ((isa<Constant>(O1) && isIdentifiedObject(O2) && !isa<Constant>(O2)) ||
+ (isa<Constant>(O2) && isIdentifiedObject(O1) && !isa<Constant>(O1)))
return NoAlias;
// Arguments can't alias with local allocations or noalias calls
// in the same function.
- if (!EffectivelyInterprocedural &&
- ((isa<Argument>(O1) && (isa<AllocaInst>(O2) || isNoAliasCall(O2))) ||
+ if (((isa<Argument>(O1) && (isa<AllocaInst>(O2) || isNoAliasCall(O2))) ||
(isa<Argument>(O2) && (isa<AllocaInst>(O1) || isNoAliasCall(O1)))))
return NoAlias;
// Most objects can't alias null.
- if ((isa<ConstantPointerNull>(V2) && isKnownNonNull(O1)) ||
- (isa<ConstantPointerNull>(V1) && isKnownNonNull(O2)))
+ if ((isa<ConstantPointerNull>(O2) && isKnownNonNull(O1)) ||
+ (isa<ConstantPointerNull>(O1) && isKnownNonNull(O2)))
return NoAlias;
}
@@ -814,7 +781,7 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
// temporary store the nocapture argument's value in a temporary memory
// location if that memory location doesn't escape. Or it may pass a
// nocapture value to other functions as long as they don't capture it.
- if (O1 != O2 && !EffectivelyInterprocedural) {
+ if (O1 != O2) {
if (isEscapeSource(O1) && isNonEscapingLocalObject(O2))
return NoAlias;
if (isEscapeSource(O2) && isNonEscapingLocalObject(O1))
@@ -850,33 +817,3 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size,
// Make sure that anything that uses AliasAnalysis pulls in this file.
DEFINING_FILE_FOR(BasicAliasAnalysis)
-
-//===----------------------------------------------------------------------===//
-// InterproceduralBasicAliasAnalysis Pass
-//===----------------------------------------------------------------------===//
-
-namespace {
- /// InterproceduralBasicAliasAnalysis - This is similar to basicaa, except
- /// that it properly supports queries to values which live in different
- /// functions.
- ///
- /// Note that we don't currently take this to the extreme, analyzing all
- /// call sites of a function to answer a query about an Argument.
- ///
- struct InterproceduralBasicAliasAnalysis : public BasicAliasAnalysis {
- static char ID; // Class identification, replacement for typeinfo
- InterproceduralBasicAliasAnalysis() : BasicAliasAnalysis(&ID, true) {}
- };
-}
-
-// Register this pass...
-char InterproceduralBasicAliasAnalysis::ID = 0;
-static RegisterPass<InterproceduralBasicAliasAnalysis>
-W("interprocedural-basic-aa", "Interprocedural Basic Alias Analysis", false, true);
-
-// Declare that we implement the AliasAnalysis interface
-static RegisterAnalysisGroup<AliasAnalysis> Z(W);
-
-ImmutablePass *llvm::createInterproceduralBasicAliasAnalysisPass() {
- return new InterproceduralBasicAliasAnalysis();
-}