[AliasSetTracker] Misc cleanup (NFCI)

Summary: Remove two redundant checks, add one in the unit test. Remove an unused method. Fix computation of TotalMayAliasSetSize.
llvm-svn: 345911
This commit is contained in:
Alina Sbirlea 2018-11-01 23:37:51 +00:00
parent d5779da11b
commit fd9722fbc6
3 changed files with 8 additions and 18 deletions

View File

@ -389,10 +389,6 @@ public:
/// set is returned.
AliasSet &getAliasSetFor(const MemoryLocation &MemLoc);
/// Return true if the specified instruction "may" (or must) alias one of the
/// members in any of the sets.
bool containsUnknown(const Instruction *I) const;
/// Return the underlying alias analysis object used by this tracker.
AliasAnalysis &getAliasAnalysis() const { return AA; }

View File

@ -114,10 +114,9 @@ void AliasSetTracker::removeAliasSet(AliasSet *AS) {
if (AliasSet *Fwd = AS->Forward) {
Fwd->dropRef(*this);
AS->Forward = nullptr;
}
if (AS->Alias == AliasSet::SetMayAlias)
TotalMayAliasSetSize -= AS->size();
} else // Update TotalMayAliasSetSize only if not forwarding.
if (AS->Alias == AliasSet::SetMayAlias)
TotalMayAliasSetSize -= AS->size();
AliasSets.erase(AS);
}
@ -232,8 +231,8 @@ bool AliasSet::aliasesUnknownInst(const Instruction *Inst,
if (AliasAny)
return true;
if (!Inst->mayReadOrWriteMemory())
return false;
assert(Inst->mayReadOrWriteMemory() &&
"Instruction must either read or write memory.");
for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) {
if (auto *UnknownInst = getUnknownInst(i)) {
@ -311,13 +310,6 @@ AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
return FoundSet;
}
bool AliasSetTracker::containsUnknown(const Instruction *Inst) const {
for (const AliasSet &AS : *this)
if (!AS.Forward && AS.aliasesUnknownInst(Inst, AA))
return true;
return false;
}
AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
AliasSet *FoundSet = nullptr;
for (iterator I = begin(), E = end(); I != E;) {
@ -326,7 +318,7 @@ AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
continue;
if (!FoundSet) // If this is the first alias set ptr can go into.
FoundSet = &*Cur; // Remember it.
else if (!Cur->Forward) // Otherwise, we must merge the sets.
else // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*Cur, *this); // Merge in contents.
}
return FoundSet;

View File

@ -78,6 +78,8 @@ TEST(AliasSetTracker, AliasUnknownInst) {
for (auto &Inst : *Test->begin()) {
bool FoundAS = false;
for (AliasSet &AS : AST) {
if (!Inst.mayReadOrWriteMemory())
continue;
if (!AS.aliasesUnknownInst(&Inst, AA))
continue;
ASSERT_NE(FoundAS, true);