This is an archive of the discontinued LLVM Phabricator instance.

[basicaa] Rewrite isGEPBaseAtNegativeOffset in terms of index difference [NFC]
ClosedPublic

Authored by reames on Feb 25 2021, 6:27 PM.

Details

Summary

This should be purely NFC, it just fits more obviously in the flow of the code now that we've standardized on the index different approach.

One subtle point - the placement of this above the BaseAlias check is important in the original code as this can return NoAlias even when we can't find a relation between the bases otherwise.

Also added some enhancement TODOs noticed while understanding the existing code.

Diff Detail

Event Timeline

reames created this revision.Feb 25 2021, 6:27 PM
reames requested review of this revision.Feb 25 2021, 6:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2021, 6:27 PM
reames updated this revision to Diff 326576.Feb 25 2021, 6:30 PM

(upload correct version of patch this time...)

nikic accepted this revision.Feb 26 2021, 4:22 AM

LGTM. Some caveats:

  • This doesn't look entirely NFC to me, because it will now strip away identical variable indices on both sides. You should be able to construct an example that changes with GEPs like gep inbounds %p, %v, C and gep inbounds %p, %v, 0.
  • The inbounds check is not correct, because DecomposeGEP looks across multiple GEPs, and this only checks that the final one is inbounds. We should probably add a flag to DecomposedGEP that indicates whether all the GEPs are inbounds (handling mixes of inbounds and non-inbounds doesn't seem worth the trouble).
This revision is now accepted and ready to land.Feb 26 2021, 4:22 AM
This revision was landed with ongoing or failed builds.Mar 3 2021, 9:03 AM
This revision was automatically updated to reflect the committed changes.