This is an archive of the discontinued LLVM Phabricator instance.

[Loads] Support SCEVAddExpr as start for pointer AddRec.
ClosedPublic

Authored by fhahn on Mar 30 2023, 12:33 PM.

Details

Summary

Extend handling to support %base + offset as start for AddRecs in
isDereferenceableAndAlignedInLoop. This is done by adjusting AccessSize
by the offset and effectively checking if the full object starting from
%base to %base + offset + access-size is dereferenceable.

Diff Detail

Event Timeline

fhahn created this revision.Mar 30 2023, 12:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 12:33 PM
fhahn requested review of this revision.Mar 30 2023, 12:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 12:33 PM
nikic requested changes to this revision.Mar 30 2023, 12:47 PM
nikic added a subscriber: nikic.
nikic added inline comments.
llvm/lib/Analysis/Loads.cpp
320

Don't you need to check that Offset is also aligned? If I'm reading this right, you'd currently accept Offset = 1 for Alignment = 4, as it is only checked against EltSize and the base pointer.

This revision now requires changes to proceed.Mar 30 2023, 12:47 PM
fhahn updated this revision to Diff 510123.Mar 31 2023, 1:36 PM

Add check if offset is aligned.

fhahn added inline comments.Mar 31 2023, 1:54 PM
llvm/lib/Analysis/Loads.cpp
320

Thanks I was assuming the total size was also checked in isDereferenceableAndAlignedPointer but that's not the case!

I added test cases for both the check of EltSize (looks like this was missing) and the check for the offset in 74dee4791a2b3f17a49ea2f90ce3730f241f36ac and 3b95c335887df73123991d023dadb36cd914fc91

nikic accepted this revision.Apr 2 2023, 1:26 AM

LGTM

llvm/lib/Analysis/Loads.cpp
308

Move assertion out of if/else? This always holds.

This revision is now accepted and ready to land.Apr 2 2023, 1:26 AM
This revision was landed with ongoing or failed builds.Apr 2 2023, 4:34 AM
This revision was automatically updated to reflect the committed changes.