This is an archive of the discontinued LLVM Phabricator instance.

[AliasSetTracker] Teach AliasSetTracker about MemSetInst
ClosedPublic

Authored by haicheng on Feb 16 2016, 12:14 PM.

Details

Summary

This change is to fix the problem discussed here.

In short, if running -licm -loop-idiom on the c-code like this

int	i, j, k;
for (i = 0; i < 1; i++) {
  for (j = 0; j < 2; j++) {
     for (k = 0; k < 10; k++) {
         a[j][k] = 42;
      }
   }
}

loop-idiom turns the store in the inner loop into a small memset in the middle loop and then the small memset into a big memset in the outer loop. But, the middle memset is already tagged by LICM as an unknown instruction in AliasSetTracker and deleting it in loop-idiom can trigger an assertion.

This patch teaches AliasSetTracker about MemSetInst. When deleting the small memset in loop-idiom, AliasSetTracker::ASTCallbackVH::deleted() can properly update the AliasSetTracker.

Diff Detail

Repository
rL LLVM

Event Timeline

haicheng updated this revision to Diff 48091.Feb 16 2016, 12:14 PM
haicheng retitled this revision from to Teach AliasSetTracker about MemSetInst.
haicheng updated this object.
haicheng added reviewers: mcrosier, mssimpso, gberry, uabelho.
haicheng set the repository for this revision to rL LLVM.
haicheng retitled this revision from Teach AliasSetTracker about MemSetInst to [AliasSetTracker] Teach AliasSetTracker about MemSetInst.Feb 16 2016, 12:17 PM
haicheng updated this object.
haicheng updated this object.Feb 16 2016, 12:33 PM
mssimpso edited edge metadata.Feb 16 2016, 1:11 PM

Looks good to me.

One comment, actually.

lib/Analysis/AliasSetTracker.cpp
513

Is MSI->getOperand(0) right? I would think we would want to use getDest() here.

mcrosier accepted this revision.Feb 16 2016, 1:31 PM
mcrosier edited edge metadata.

LGTM, with a small request.

lib/Analysis/AliasSetTracker.cpp
540–541

Please add a FIXME comment for memcpy and memmov. Feel free to fix the issue in a later patch, if you like. Alternatively, please file a bug.

This revision is now accepted and ready to land.Feb 16 2016, 1:31 PM
mcrosier edited edge metadata.Feb 16 2016, 1:32 PM
mcrosier added a subscriber: llvm-commits.

Please make sure to include the commit-list when you post the patch. Regardless, I think this one is good to go in..

haicheng updated this revision to Diff 48109.Feb 16 2016, 2:53 PM

Address Matt and Chad's comments.

haicheng marked 2 inline comments as done.Feb 16 2016, 2:53 PM
uabelho edited edge metadata.Feb 16 2016, 11:29 PM

I'm not very familiar with this code but at least I've verified it to solve my original problem. Thanks!

LGTM. Feel free to commit. Thanks, Haicheng.

haicheng closed this revision.Feb 17 2016, 12:11 PM

Committed in r261052.