This is an archive of the discontinued LLVM Phabricator instance.

[AliasSetTracker] Don't drop AA MD so eagerly
ClosedPublic

Authored by loladiro on Apr 17 2017, 2:32 PM.

Details

Summary

When we have patterns like
loop:

%la = load %ptr, !tbaa
%lba = load %ptr, !tbaa !noalias

AliasSetTracker would previously think that the two types of annotation for
the pointer conflict, dropping both for the purpose of determining alias sets.
That is clearly way too conservative, as the tbaa is still valid whether or
not one of the memory accesses has additional AA metadata. We could go
one step further and attempt to properly merge the noalias metadata,
but it's not clear that that would be worth it since that may introduce
additional MD nodes, which may be undesirable since this is merely an
Analysis. For now, just take care of the simple case above, and keep
dropping conflicting noalias and alias.scope metadata, but keep tbaa
if it matches.

Event Timeline

loladiro created this revision.Apr 17 2017, 2:32 PM
hfinkel added inline comments.Jun 20 2017, 4:07 PM
include/llvm/Analysis/AliasSetTracker.h
77

I'd prefer that we handle this in a way that the symmetric between the TBAA and NoAlias metadata. If TBAA conflict, set TBAA to nullptr. If NoAlias conflict, set NoAlias to nullptr, same with Scope. Please put this part of the logic into a member function on AAMDNodes (so that we can keep it in sync with anything else we add there). If there's nothing left (i.e. AAMDNodes's operator bool returns false), then set AAInfo to getTombstoneKey().

loladiro updated this revision to Diff 104536.Jun 28 2017, 4:03 PM

Factor out intersection code into a method of AAMDNodes

hfinkel accepted this revision.Jun 29 2017, 7:18 AM

LGTM

This revision is now accepted and ready to land.Jun 29 2017, 7:18 AM
This revision was automatically updated to reflect the committed changes.