[AST] Cleanup code by using MemoryLocation utility [NFC]

Differential Revision: https://reviews.llvm.org/D50588



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339625 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Philip Reames
2018-08-13 22:25:16 +00:00
parent 656d5d59d3
commit 5fada2e94d
2 changed files with 15 additions and 43 deletions
+4
View File
@@ -461,6 +461,10 @@ private:
AliasSet &addPointer(Value *P, LocationSize Size, const AAMDNodes &AAInfo,
AliasSet::AccessLattice E);
AliasSet &addPointer(MemoryLocation Loc,
AliasSet::AccessLattice E) {
return addPointer(const_cast<Value*>(Loc.Ptr), Loc.Size, Loc.AATags, E);
}
AliasSet *mergeAliasSetsForPointer(const Value *Ptr, LocationSize Size,
const AAMDNodes &AAInfo);
+11 -43
View File
@@ -357,71 +357,39 @@ void AliasSetTracker::add(Value *Ptr, LocationSize Size,
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<ConstantInt>(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<MemSetInst>(MSI);
if (MS && MS->isVolatile())
AS.setVolatile();
}
void AliasSetTracker::add(AnyMemTransferInst *MTI) {
AAMDNodes AAInfo;
MTI->getAAMetadata(AAInfo);
auto SrcLoc = MemoryLocation::getForSource(MTI);
auto DestLoc = MemoryLocation::getForDest(MTI);
uint64_t Len;
if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
Len = C->getZExtValue();
else
Len = MemoryLocation::UnknownSize;
AliasSet &ASSrc = addPointer(SrcLoc, AliasSet::RefAccess);
AliasSet &ASSrc =
addPointer(MTI->getRawSource(), Len, AAInfo, AliasSet::RefAccess);
AliasSet &ASDst =
addPointer(MTI->getRawDest(), Len, AAInfo, AliasSet::ModAccess);
AliasSet &ASDst = addPointer(DestLoc, AliasSet::ModAccess);
auto* MT = dyn_cast<MemTransferInst>(MTI);
if (MT && MT->isVolatile()) {