From fd9722fbc6141ebaaa4f1e7f058457e0a7d460f4 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Thu, 1 Nov 2018 23:37:51 +0000 Subject: [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 --- llvm/lib/Analysis/AliasSetTracker.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'llvm/lib/Analysis/AliasSetTracker.cpp') diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp index 22c8ae20113..c152b0ddeca 100644 --- a/llvm/lib/Analysis/AliasSetTracker.cpp +++ b/llvm/lib/Analysis/AliasSetTracker.cpp @@ -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; -- cgit v1.2.3