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::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::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 { 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