From 9e86f4364b912ae743490ba01d6989acfd12c046 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 7 Jul 2010 14:27:09 +0000 Subject: 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 --- lib/Analysis/BasicAliasAnalysis.cpp | 91 ++++++------------------------------- 1 file changed, 14 insertions(+), 77 deletions(-) (limited to 'lib/Analysis/BasicAliasAnalysis.cpp') 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(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(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(O1) && - isIdentifiedObject(O2, EffectivelyInterprocedural) && - !isa(O2)) || - (isa(O2) && - isIdentifiedObject(O1, EffectivelyInterprocedural) && - !isa(O1))) + if ((isa(O1) && isIdentifiedObject(O2) && !isa(O2)) || + (isa(O2) && isIdentifiedObject(O1) && !isa(O1))) return NoAlias; // Arguments can't alias with local allocations or noalias calls // in the same function. - if (!EffectivelyInterprocedural && - ((isa(O1) && (isa(O2) || isNoAliasCall(O2))) || + if (((isa(O1) && (isa(O2) || isNoAliasCall(O2))) || (isa(O2) && (isa(O1) || isNoAliasCall(O1))))) return NoAlias; // Most objects can't alias null. - if ((isa(V2) && isKnownNonNull(O1)) || - (isa(V1) && isKnownNonNull(O2))) + if ((isa(O2) && isKnownNonNull(O1)) || + (isa(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 -W("interprocedural-basic-aa", "Interprocedural Basic Alias Analysis", false, true); - -// Declare that we implement the AliasAnalysis interface -static RegisterAnalysisGroup Z(W); - -ImmutablePass *llvm::createInterproceduralBasicAliasAnalysisPass() { - return new InterproceduralBasicAliasAnalysis(); -} -- cgit v1.2.3