This is an archive of the discontinued LLVM Phabricator instance.

[DependenceAnalysis] Make sure base objects are the same when comparing GEPs
ClosedPublic

Authored by bcahoon on Jun 27 2017, 11:31 AM.

Details

Summary

The dependence analysis was returning incorrect information when using the GEPs to compute the dependence. The analysis uses the GEP indices to perform the check under certain conditions. It incorrectly does this if the base objects are aliases, but are actually pointing to different locations in an array. Because the SCEVs for the GEPs indices were the same, DA returns a distance of 0.

This patch adds another check for the base objects. If the SCEVs for the base pointers are compared, using getMinusSCEV() and the value is not 0, the analysis should fall back on the path that uses the whole SCEV for the dependence check. Not just the GEP indices.

Fixes bug 33567.

Diff Detail

Repository
rL LLVM

Event Timeline

bcahoon created this revision.Jun 27 2017, 11:31 AM
philip.pfaffe edited edge metadata.Jun 28 2017, 3:16 AM

The idea seems solid. Can you merge the testcases into one? If the testcase is named BasePtrBug, please also add the bug id, either in the name directly or in a comment inside.

lib/Analysis/DependenceAnalysis.cpp
3340 ↗(On Diff #104221)

Why did you choose to look at the difference instead of checking isKnownPredicate? Is there an advantage in looking at the difference? isKnownPredicate would communicate to the reader better the intention of this check.

test/Analysis/DependenceAnalysis/BasePtrBug1.ll
4 ↗(On Diff #104221)

"generates" and "different"

bcahoon updated this revision to Diff 104460.Jun 28 2017, 10:49 AM

Hi Philip - thanks for the review. I made the changes you suggested.

This version uses isKnownPredicate to compare the base pointers. I've combined the two test cases in to file.

philip.pfaffe accepted this revision.Jul 3 2017, 8:25 AM

One formatting nit aside, LGMT.

test/Analysis/DependenceAnalysis/BasePtrBug.ll
8 ↗(On Diff #104460)

Indentation

This revision is now accepted and ready to land.Jul 3 2017, 8:25 AM
This revision was automatically updated to reflect the committed changes.