This is an archive of the discontinued LLVM Phabricator instance.

Fix memcheck interval ends for pointers with negative strides
ClosedPublic

Authored by sbaranga on Jul 13 2015, 8:47 AM.

Details

Summary

The checking pointer grouping algorithm assumes that the
starts/ends of the pointers are well formed (start <= end).

The runtime memory checking algorithm also assumes this by doing:

start0 < end1 && start1 < end0

to detect conflicts. This check only works if start0 <= end0 and
start1 <= end1.

This change correctly orders the interval ends by either checking
the stride (if it is constant) or by using min/max SCEV expressions.

Diff Detail

Event Timeline

sbaranga updated this revision to Diff 29580.Jul 13 2015, 8:47 AM
sbaranga retitled this revision from to Fix memcheck interval ends for pointers with negative strides.
sbaranga updated this object.
sbaranga added a reviewer: anemet.
sbaranga added a subscriber: llvm-commits.
anemet edited edge metadata.Jul 14 2015, 11:33 AM

Is this a preexisting bug to grouping pointers? IOW, did we handle swapping start and end like this for pointers before your change?

If this was a bug even before, we probably want to benchmark this to avoid surprises. (In theory we could have had a case where the memchecks should have failed but did not but do after your change.)

Please also add a test for the non-constant case.

Thanks!

lib/Analysis/LoopAccessAnalysis.cpp
144–147

Nit: you can assign to ScStart and ScEnd directly.

anemet accepted this revision.Jul 14 2015, 11:34 AM
anemet edited edge metadata.

Forgot to add that LGTM :)

This revision is now accepted and ready to land.Jul 14 2015, 11:34 AM

Is this a preexisting bug to grouping pointers? IOW, did we handle swapping start and end like this for pointers before your change?

Yes, this was a pre-existing bug. Now the pointer grouping would just make it more difficult for someone to debug if they would hit this issue (besides also relying on this).

If this was a bug even before, we probably want to benchmark this to avoid surprises. (In theory we could have had a case where the memchecks should have failed but did not but do after your change.)

Correct. I'm running benchmarks now. Hopefully we won't get any regressions.

Please also add a test for the non-constant case.

Thanks!

Thanks,
Silviu

sbaranga updated this revision to Diff 29897.Jul 16 2015, 6:20 AM
sbaranga edited edge metadata.

Rebase and add a test for the non-constant stride case.

rengolin accepted this revision.Jul 16 2015, 6:34 AM
rengolin added a reviewer: rengolin.
rengolin added a subscriber: rengolin.

Nice catch! LGTM too.

Have we regressed anything? I seriously doubt it, but it's always good to check.

cheers,
--renato

Hi Renato,

Nice catch! LGTM too.

Have we regressed anything? I seriously doubt it, but it's always good to check.

cheers,
--renato

Thanks! I've tested with the llvm test suite, spec2000 and spec2006 for aarch64. I didn't see any regressions. I've seen some potential improvements in some spec benchmarks, but I think it is only noise.

-Silviu

lib/Analysis/LoopAccessAnalysis.cpp
144–147

Looks like I've missed this comment, will fix before committing.

sbaranga updated this revision to Diff 29901.Jul 16 2015, 7:00 AM
sbaranga edited edge metadata.

Remove the temporaries Min and Max, since we can do the operation without using them.

sbaranga closed this revision.Jul 16 2015, 7:03 AM

Committed in r242400!

> Thanks! I've tested with the llvm test suite, spec2000 and spec2006 for aarch64. I didn't see any regressions. I've seen some potential improvements in some spec benchmarks, but I think it is only noise.

Great, thanks for your work.

klimek added a subscriber: klimek.Jul 27 2015, 4:55 AM

Test for bouncing, ignore.