This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA/MDA] Sink aliasing rules for malloc and calloc into BasicAA
ClosedPublic

Authored by reames on Jan 5 2016, 8:10 PM.

Details

Summary

MemoryDependenceAnalysis had a hard-coded exception to the general aliasing rules for malloc and calloc. The reasoning that applied there is equally valid in BasicAA and clarifies the remaining logic in MDA.

In principal, this can expose slightly more optimization opportunities, but since essentially all of our aliasing aware memory optimization passes go through MDA, this will likely be NFC in practice.

Diff Detail

Event Timeline

reames updated this revision to Diff 44081.Jan 5 2016, 8:10 PM
reames retitled this revision from to [BasicAA/MDA] Sink aliasing rules for malloc and calloc into BasicAA.
reames updated this object.
reames added reviewers: hfinkel, nlopes, dberlin.
reames added a subscriber: llvm-commits.
dberlin accepted this revision.Mar 9 2016, 12:39 PM
dberlin edited edge metadata.

LGTM

lib/Analysis/BasicAliasAnalysis.cpp
744

What happens to alloca here?

This revision is now accepted and ready to land.Mar 9 2016, 12:39 PM
reames added inline comments.Mar 9 2016, 2:14 PM
lib/Analysis/BasicAliasAnalysis.cpp
744

Nothing, it's not a call site.

I think what you're getting at is whether we need alloca handling in MDA. The flow there is unchanged. The mustalias (early def) case is exactly the same and Alloca's don't modify memory so we explicitly skip over them. The previous code would have either early continued or hit the NoModRef case inside getModRefInfo(Instruction*, MemLoc); in either case, we skip the alloca.

Actually, that points out the isa<AllocaInst> check I added in MDA is completely redundant. I'll; remove that.

Sorry. I realized exactly what you said and thought i removed the comment,
but apparently not :)

This revision was automatically updated to reflect the committed changes.