diff options
| author | Alina Sbirlea <asbirlea@google.com> | 2018-11-01 23:37:51 +0000 |
|---|---|---|
| committer | Alina Sbirlea <asbirlea@google.com> | 2018-11-01 23:37:51 +0000 |
| commit | fd9722fbc6141ebaaa4f1e7f058457e0a7d460f4 (patch) | |
| tree | ebec8de033eb848f1f3e4854ac43d04ab62dd62c /llvm | |
| parent | d5779da11be0b289665499996ef4bcc92fd36714 (diff) | |
| download | bcm5719-llvm-fd9722fbc6141ebaaa4f1e7f058457e0a7d460f4.tar.gz bcm5719-llvm-fd9722fbc6141ebaaa4f1e7f058457e0a7d460f4.zip | |
[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
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Analysis/AliasSetTracker.h | 4 | ||||
| -rw-r--r-- | llvm/lib/Analysis/AliasSetTracker.cpp | 20 | ||||
| -rw-r--r-- | llvm/unittests/Analysis/AliasSetTrackerTest.cpp | 2 |
3 files changed, 8 insertions, 18 deletions
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h index d24453749fe..7ed5cd5c473 100644 --- a/llvm/include/llvm/Analysis/AliasSetTracker.h +++ b/llvm/include/llvm/Analysis/AliasSetTracker.h @@ -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; } 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; diff --git a/llvm/unittests/Analysis/AliasSetTrackerTest.cpp b/llvm/unittests/Analysis/AliasSetTrackerTest.cpp index 886971c4d3a..57d21e2fcb8 100644 --- a/llvm/unittests/Analysis/AliasSetTrackerTest.cpp +++ b/llvm/unittests/Analysis/AliasSetTrackerTest.cpp @@ -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); |

