This is an archive of the discontinued LLVM Phabricator instance.

Fix BasicAA incorrect assumption on GEP
ClosedPublic

Authored by mehdi_amini on Jan 27 2017, 12:12 AM.

Details

Summary

This is fixing pr31761: BasicAA is deducing NoAlias
on the result of the GEP if the base pointer is itself NoAlias.

This is possible only if the NoAlias on the base pointer is
deduced with a non-sized query: this should guarantee that
the pointers are belonging to different memory allocation
and that the GEP can't legally jump from one to another.

Diff Detail

Repository
rL LLVM

Event Timeline

mehdi_amini created this revision.Jan 27 2017, 12:12 AM

Update after discussing with Chandler on IRC: making the query unsized should be enough here!

If we deduce NoAlias with an unsized query, it should mean that a GEP can't
reach one allocation from another.

mehdi_amini edited the summary of this revision. (Show Details)Jan 27 2017, 12:34 AM
hfinkel accepted this revision.Jan 27 2017, 6:04 AM

LGTM. This should go into the branch too.

llvm/lib/Analysis/BasicAliasAnalysis.cpp
1194 ↗(On Diff #86027)

I had to look at this for a few moments to realize why this was broken: UnknownSize might be unknown, but it is still assumed to be positive, so we only get a one-sided range. Thus, we must use UnknownSize for both sizes.

llvm/test/Transforms/SLPVectorizer/X86/tiny-tree.ll
5 ↗(On Diff #86027)

We don't need to touch this file now.

This revision is now accepted and ready to land.Jan 27 2017, 6:04 AM
This revision was automatically updated to reflect the committed changes.