[llvm] r345911 - [AliasSetTracker] Misc cleanup (NFCI)

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 1 16:37:51 PDT 2018


Author: asbirlea
Date: Thu Nov  1 16:37:51 2018
New Revision: 345911

URL: http://llvm.org/viewvc/llvm-project?rev=345911&view=rev
Log:
[AliasSetTracker] Misc cleanup (NFCI)

Summary: Remove two redundant checks, add one in the unit test. Remove an unused method. Fix computation of TotalMayAliasSetSize.

Modified:
    llvm/trunk/include/llvm/Analysis/AliasSetTracker.h
    llvm/trunk/lib/Analysis/AliasSetTracker.cpp
    llvm/trunk/unittests/Analysis/AliasSetTrackerTest.cpp

Modified: llvm/trunk/include/llvm/Analysis/AliasSetTracker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasSetTracker.h?rev=345911&r1=345910&r2=345911&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasSetTracker.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasSetTracker.h Thu Nov  1 16:37:51 2018
@@ -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; }
 

Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=345911&r1=345910&r2=345911&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Thu Nov  1 16:37:51 2018
@@ -114,10 +114,9 @@ void AliasSetTracker::removeAliasSet(Ali
   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
   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::mergeAliasSet
   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::findAliasSetF
       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;

Modified: llvm/trunk/unittests/Analysis/AliasSetTrackerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/AliasSetTrackerTest.cpp?rev=345911&r1=345910&r2=345911&view=diff
==============================================================================
--- llvm/trunk/unittests/Analysis/AliasSetTrackerTest.cpp (original)
+++ llvm/trunk/unittests/Analysis/AliasSetTrackerTest.cpp Thu Nov  1 16:37:51 2018
@@ -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);




More information about the llvm-commits mailing list