This is an archive of the discontinued LLVM Phabricator instance.

[AliasAnalysis] Fences do not modify constant memory location
ClosedPublic

Authored by anna on Jan 19 2017, 1:12 PM.

Details

Summary

Fence instructions are currently marked as ModRef for all memory locations.

We can improve this for constant memory locations (such as constant globals),
since fence instructions cannot modify these locations.

This helps us to forward constant loads across fences (added test case in GVN).
There were no changes in behaviour for similar test cases in early-cse and licm.

Diff Detail

Repository
rL LLVM

Event Timeline

anna created this revision.Jan 19 2017, 1:12 PM
dberlin edited edge metadata.Jan 19 2017, 1:39 PM

Even though most AA related calls will crash trying to get a memorylocation from the fence, this looks right..

Please add the same change to NewGVN/fence.ll

anna updated this revision to Diff 85029.Jan 19 2017, 2:13 PM

Added test case to NewGVN as well.

anna added a comment.Jan 19 2017, 2:17 PM

Hi Daniel,

Even though most AA related calls will crash trying to get a memorylocation from the fence, this looks right..

I've seen the lack of memory locations in optimizations when using memssa version for optimizations. So, in such cases, it would still return ModRef.

dberlin accepted this revision.Jan 19 2017, 2:20 PM

Somewhere on my todo list is to cleanup getModRefInfo, and make getModRefInfo the only interface memssa uses.
Right now, it has to differentiate between calls, fences, and other things to call the right versions.

Interestingly, fences are the only memory modification instruction we have that has no location, and if you call memorylocation::get on them, we crash.

This revision is now accepted and ready to land.Jan 19 2017, 2:21 PM
This revision was automatically updated to reflect the committed changes.