X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FAliasSetTracker.cpp;h=608da93f5738a4725f007ae5eca87d3090b940a3;hb=6b38e29f13cb8700146e4b170567e2828553db9a;hp=366909c0ebeb370e0a835b996b02e80326a13d99;hpb=cb406c25973b4e88a6c10ad839ef1beeb3664715;p=oota-llvm.git diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 366909c0ebe..608da93f573 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -114,15 +114,13 @@ void AliasSet::addPointer(AliasSetTracker &AST, HashNodePair &Entry, void AliasSet::addCallSite(CallSite CS, AliasAnalysis &AA) { CallSites.push_back(CS); - if (Function *F = CS.getCalledFunction()) { - AliasAnalysis::ModRefBehavior Behavior = AA.getModRefBehavior(F, CS); - if (Behavior == AliasAnalysis::DoesNotAccessMemory) - return; - else if (Behavior == AliasAnalysis::OnlyReadsMemory) { - AliasTy = MayAlias; - AccessTy |= Refs; - return; - } + AliasAnalysis::ModRefBehavior Behavior = AA.getModRefBehavior(CS); + if (Behavior == AliasAnalysis::DoesNotAccessMemory) + return; + else if (Behavior == AliasAnalysis::OnlyReadsMemory) { + AliasTy = MayAlias; + AccessTy |= Refs; + return; } // FIXME: This should use mod/ref information to make this not suck so bad @@ -166,9 +164,8 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size, } bool AliasSet::aliasesCallSite(CallSite CS, AliasAnalysis &AA) const { - if (Function *F = CS.getCalledFunction()) - if (AA.doesNotAccessMemory(F)) - return false; + if (AA.doesNotAccessMemory(CS)) + return false; if (AA.hasNoModRefInfoForCalls()) return true; @@ -269,7 +266,7 @@ bool AliasSetTracker::add(Value *Ptr, unsigned Size) { bool AliasSetTracker::add(LoadInst *LI) { bool NewPtr; AliasSet &AS = addPointer(LI->getOperand(0), - AA.getTargetData().getTypeSize(LI->getType()), + AA.getTargetData().getTypeStoreSize(LI->getType()), AliasSet::Refs, NewPtr); if (LI->isVolatile()) AS.setVolatile(); return NewPtr; @@ -279,7 +276,7 @@ bool AliasSetTracker::add(StoreInst *SI) { bool NewPtr; Value *Val = SI->getOperand(0); AliasSet &AS = addPointer(SI->getOperand(1), - AA.getTargetData().getTypeSize(Val->getType()), + AA.getTargetData().getTypeStoreSize(Val->getType()), AliasSet::Mods, NewPtr); if (SI->isVolatile()) AS.setVolatile(); return NewPtr; @@ -287,19 +284,20 @@ bool AliasSetTracker::add(StoreInst *SI) { bool AliasSetTracker::add(FreeInst *FI) { bool NewPtr; - AliasSet &AS = addPointer(FI->getOperand(0), ~0, - AliasSet::Mods, NewPtr); + addPointer(FI->getOperand(0), ~0, AliasSet::Mods, NewPtr); + return NewPtr; +} - // Free operations are volatile ops (cannot be moved). - AS.setVolatile(); +bool AliasSetTracker::add(VAArgInst *VAAI) { + bool NewPtr; + addPointer(VAAI->getOperand(0), ~0, AliasSet::ModRef, NewPtr); return NewPtr; } bool AliasSetTracker::add(CallSite CS) { - if (Function *F = CS.getCalledFunction()) - if (AA.doesNotAccessMemory(F)) - return true; // doesn't alias anything + if (AA.doesNotAccessMemory(CS)) + return true; // doesn't alias anything AliasSet *AS = findAliasSetForCallSite(CS); if (!AS) { @@ -325,6 +323,8 @@ bool AliasSetTracker::add(Instruction *I) { return add(II); else if (FreeInst *FI = dyn_cast(I)) return add(FI); + else if (VAArgInst *VAAI = dyn_cast(I)) + return add(VAAI); return true; } @@ -395,7 +395,7 @@ bool AliasSetTracker::remove(Value *Ptr, unsigned Size) { } bool AliasSetTracker::remove(LoadInst *LI) { - unsigned Size = AA.getTargetData().getTypeSize(LI->getType()); + unsigned Size = AA.getTargetData().getTypeStoreSize(LI->getType()); AliasSet *AS = findAliasSetForPointer(LI->getOperand(0), Size); if (!AS) return false; remove(*AS); @@ -403,7 +403,8 @@ bool AliasSetTracker::remove(LoadInst *LI) { } bool AliasSetTracker::remove(StoreInst *SI) { - unsigned Size = AA.getTargetData().getTypeSize(SI->getOperand(0)->getType()); + unsigned Size = + AA.getTargetData().getTypeStoreSize(SI->getOperand(0)->getType()); AliasSet *AS = findAliasSetForPointer(SI->getOperand(1), Size); if (!AS) return false; remove(*AS); @@ -417,10 +418,16 @@ bool AliasSetTracker::remove(FreeInst *FI) { return true; } +bool AliasSetTracker::remove(VAArgInst *VAAI) { + AliasSet *AS = findAliasSetForPointer(VAAI->getOperand(0), ~0); + if (!AS) return false; + remove(*AS); + return true; +} + bool AliasSetTracker::remove(CallSite CS) { - if (Function *F = CS.getCalledFunction()) - if (AA.doesNotAccessMemory(F)) - return false; // doesn't alias anything + if (AA.doesNotAccessMemory(CS)) + return false; // doesn't alias anything AliasSet *AS = findAliasSetForCallSite(CS); if (!AS) return false; @@ -438,6 +445,8 @@ bool AliasSetTracker::remove(Instruction *I) { return remove(CI); else if (FreeInst *FI = dyn_cast(I)) return remove(FI); + else if (VAArgInst *VAAI = dyn_cast(I)) + return remove(VAAI); return true; } @@ -454,13 +463,10 @@ void AliasSetTracker::deleteValue(Value *PtrVal) { // If this is a call instruction, remove the callsite from the appropriate // AliasSet. CallSite CS = CallSite::get(PtrVal); - if (CS.getInstruction()) { - Function *F = CS.getCalledFunction(); - if (!F || !AA.doesNotAccessMemory(F)) { + if (CS.getInstruction()) + if (!AA.doesNotAccessMemory(CS)) if (AliasSet *AS = findAliasSetForCallSite(CS)) AS->removeCallSite(CS); - } - } // First, look up the PointerRec for this pointer. hash_map::iterator I = PointerMap.find(PtrVal); @@ -507,7 +513,7 @@ void AliasSetTracker::copyValue(Value *From, Value *To) { void AliasSet::print(std::ostream &OS) const { OS << " AliasSet[" << (void*)this << "," << RefCount << "] "; - OS << (AliasTy == MustAlias ? "must" : "may ") << " alias, "; + OS << (AliasTy == MustAlias ? "must" : "may") << " alias, "; switch (AccessTy) { case NoModRef: OS << "No access "; break; case Refs : OS << "Ref "; break; @@ -558,7 +564,7 @@ namespace { AliasSetTracker *Tracker; public: static char ID; // Pass identification, replacement for typeid - AliasSetPrinter() : FunctionPass((intptr_t)&ID) {} + AliasSetPrinter() : FunctionPass(&ID) {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); @@ -575,6 +581,8 @@ namespace { return false; } }; - char AliasSetPrinter::ID = 0; - RegisterPass X("print-alias-sets", "Alias Set Printer"); } + +char AliasSetPrinter::ID = 0; +static RegisterPass +X("print-alias-sets", "Alias Set Printer", false, true);