This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA] Generalize recursive phi alias analysis
ClosedPublic

Authored by nikic on Nov 21 2020, 9:04 AM.

Details

Summary

For recursive phis, we skip the recursive operands and check that the remaining operands are NoAlias with an unknown size. Currently, this is limited to inbounds GEPs with positive offsets, to guarantee that the recursion only ever increases the pointer.

Make this more general by only requiring that the underlying object of the phi operand is the phi itself, i.e. it it based on itself in some way. To compensate, we need to use a beforeOrAfterPointer() location size, as we no longer have the guarantee that the pointer is strictly increasing.

This allows us to handle some additional cases like negative geps, geps with dynamic offsets or geps that aren't inbounds.

Diff Detail

Event Timeline

nikic created this revision.Nov 21 2020, 9:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2020, 9:04 AM
nikic requested review of this revision.Nov 21 2020, 9:04 AM

Nice. Sounds good to me, from what I can remember about this, so long as others agree.

asbirlea accepted this revision.Nov 24 2020, 4:10 PM

sgtm too.

This revision is now accepted and ready to land.Nov 24 2020, 4:10 PM
This revision was landed with ongoing or failed builds.Nov 29 2020, 1:25 AM
This revision was automatically updated to reflect the committed changes.