Index: llvm/trunk/include/llvm/Analysis/AliasSetTracker.h =================================================================== --- llvm/trunk/include/llvm/Analysis/AliasSetTracker.h +++ llvm/trunk/include/llvm/Analysis/AliasSetTracker.h @@ -461,6 +461,10 @@ AliasSet &addPointer(Value *P, LocationSize Size, const AAMDNodes &AAInfo, AliasSet::AccessLattice E); + AliasSet &addPointer(MemoryLocation Loc, + AliasSet::AccessLattice E) { + return addPointer(const_cast(Loc.Ptr), Loc.Size, Loc.AATags, E); + } AliasSet *mergeAliasSetsForPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo); Index: llvm/trunk/lib/Analysis/AliasSetTracker.cpp =================================================================== --- llvm/trunk/lib/Analysis/AliasSetTracker.cpp +++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp @@ -357,71 +357,39 @@ void AliasSetTracker::add(LoadInst *LI) { if (isStrongerThanMonotonic(LI->getOrdering())) return addUnknown(LI); - AAMDNodes AAInfo; - LI->getAAMetadata(AAInfo); - - AliasSet::AccessLattice Access = AliasSet::RefAccess; - const DataLayout &DL = LI->getModule()->getDataLayout(); - AliasSet &AS = addPointer(LI->getOperand(0), - DL.getTypeStoreSize(LI->getType()), AAInfo, Access); + auto MemLoc = MemoryLocation::get(LI); + AliasSet &AS = addPointer(MemLoc, AliasSet::RefAccess); if (LI->isVolatile()) AS.setVolatile(); } void AliasSetTracker::add(StoreInst *SI) { if (isStrongerThanMonotonic(SI->getOrdering())) return addUnknown(SI); - AAMDNodes AAInfo; - SI->getAAMetadata(AAInfo); - - AliasSet::AccessLattice Access = AliasSet::ModAccess; - const DataLayout &DL = SI->getModule()->getDataLayout(); - Value *Val = SI->getOperand(0); - AliasSet &AS = addPointer( - SI->getOperand(1), DL.getTypeStoreSize(Val->getType()), AAInfo, Access); + auto MemLoc = MemoryLocation::get(SI); + AliasSet &AS = addPointer(MemLoc, AliasSet::ModAccess); if (SI->isVolatile()) AS.setVolatile(); } void AliasSetTracker::add(VAArgInst *VAAI) { - AAMDNodes AAInfo; - VAAI->getAAMetadata(AAInfo); - - addPointer(VAAI->getOperand(0), MemoryLocation::UnknownSize, AAInfo, + addPointer(MemoryLocation::get(VAAI), AliasSet::ModRefAccess); } void AliasSetTracker::add(AnyMemSetInst *MSI) { - AAMDNodes AAInfo; - MSI->getAAMetadata(AAInfo); - - uint64_t Len; - - if (ConstantInt *C = dyn_cast(MSI->getLength())) - Len = C->getZExtValue(); - else - Len = MemoryLocation::UnknownSize; - - AliasSet &AS = - addPointer(MSI->getRawDest(), Len, AAInfo, AliasSet::ModAccess); + auto MemLoc = MemoryLocation::getForDest(MSI); + AliasSet &AS = addPointer(MemLoc, AliasSet::ModAccess); auto *MS = dyn_cast(MSI); if (MS && MS->isVolatile()) AS.setVolatile(); } void AliasSetTracker::add(AnyMemTransferInst *MTI) { - AAMDNodes AAInfo; - MTI->getAAMetadata(AAInfo); - - uint64_t Len; - if (ConstantInt *C = dyn_cast(MTI->getLength())) - Len = C->getZExtValue(); - else - Len = MemoryLocation::UnknownSize; + auto SrcLoc = MemoryLocation::getForSource(MTI); + auto DestLoc = MemoryLocation::getForDest(MTI); - AliasSet &ASSrc = - addPointer(MTI->getRawSource(), Len, AAInfo, AliasSet::RefAccess); + AliasSet &ASSrc = addPointer(SrcLoc, AliasSet::RefAccess); - AliasSet &ASDst = - addPointer(MTI->getRawDest(), Len, AAInfo, AliasSet::ModAccess); + AliasSet &ASDst = addPointer(DestLoc, AliasSet::ModAccess); auto* MT = dyn_cast(MTI); if (MT && MT->isVolatile()) {