[PATCH] D67305: [AliasSetTracker] Update AAInfo check.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 13:38:33 PDT 2019


asbirlea updated this revision to Diff 219596.
asbirlea marked 5 inline comments as done.
asbirlea added a comment.

Update based on comments.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67305/new/

https://reviews.llvm.org/D67305

Files:
  include/llvm/Analysis/AliasSetTracker.h
  lib/Analysis/AliasSetTracker.cpp


Index: lib/Analysis/AliasSetTracker.cpp
===================================================================
--- lib/Analysis/AliasSetTracker.cpp
+++ lib/Analysis/AliasSetTracker.cpp
@@ -126,6 +126,8 @@
   AST.removeAliasSet(this);
 }
 
+/// Add Entry to the current AliasSet, all potential set merges needed were done
+/// prior to this call. Update the info stored in Entry.
 void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
                           LocationSize Size, const AAMDNodes &AAInfo,
                           bool KnownMustAlias, bool SkipSizeUpdate) {
@@ -370,7 +372,7 @@
   bool MustAliasAll = false;
   // Check to see if the pointer is already known.
   if (Entry.hasAliasSet()) {
-    // If the size changed, we may need to merge several alias sets.
+    // If the size or aainfo changed, we may need to merge several alias sets.
     // Note that we can *not* return the result of mergeAliasSetsForPointer
     // due to a quirk of alias analysis behavior. Since alias(undef, undef)
     // is NoAlias, mergeAliasSetsForPointer(undef, ...) will not find the
Index: include/llvm/Analysis/AliasSetTracker.h
===================================================================
--- include/llvm/Analysis/AliasSetTracker.h
+++ include/llvm/Analysis/AliasSetTracker.h
@@ -74,8 +74,12 @@
       return &NextInList;
     }
 
+    /// Update the size and aainfo for the current PointerRec, and return true
+    /// if a change was made that would trigger the need to merge alias sets.
     bool updateSizeAndAAInfo(LocationSize NewSize, const AAMDNodes &NewAAInfo) {
-      bool SizeChanged = false;
+      bool SizeChanged = false, AAInfoChanged = false;
+      // If the new size is different, update the size of the current pointer
+      // record to the union of the old and new sizes.
       if (NewSize != Size) {
         LocationSize OldSize = Size;
         Size = isSizeSet() ? Size.unionWith(NewSize) : NewSize;
@@ -85,17 +89,15 @@
       if (AAInfo == DenseMapInfo<AAMDNodes>::getEmptyKey())
         // We don't have a AAInfo yet. Set it to NewAAInfo.
         AAInfo = NewAAInfo;
-      else {
-        AAMDNodes Intersection(AAInfo.intersect(NewAAInfo));
-        if (!Intersection.TBAA || !Intersection.Scope ||
-            !Intersection.NoAlias) {
-          // NewAAInfo conflicts with AAInfo.
-          AAInfo = DenseMapInfo<AAMDNodes>::getTombstoneKey();
-          SizeChanged = true;
-        }
-        AAInfo = Intersection;
+      else if (AAInfo.TBAA != NewAAInfo.TBAA ||
+            AAInfo.Scope != NewAAInfo.Scope ||
+            AAInfo.NoAlias != NewAAInfo.NoAlias) {
+        // If there is a mismatch in AAInfo, use the intersection (set to
+        // nullptr all the AAInfo nodes that are different).
+        AAInfo = AAInfo.intersect(NewAAInfo);
+        AAInfoChanged = true;
       }
-      return SizeChanged;
+      return SizeChanged || AAInfoChanged;
     }
 
     LocationSize getSize() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67305.219596.patch
Type: text/x-patch
Size: 2970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190910/b2fecd70/attachment.bin>


More information about the llvm-commits mailing list