This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA] Replace VisitedPhiBBs with a single flag
ClosedPublic

Authored by nikic on Oct 18 2022, 7:18 AM.

Details

Summary

When looking through phis, BasicAA has to guard against the possibility that values from two separate cycle iterations are being compared -- in this case, even though the SSA values may be the same, they cannot be considered as equal.

This is currently done by keeping a set of VisitedPhiBBs for any phis we looked through, and then checking whether the relevant instruction is reachable from one of the phis.

This patch replaces this set with a single flag. If the flag is set, then we will not assume equality for any instruction part of a cycle. While this is nominally less accurate, it makes essentially no difference in practice. Here are the AA stats for test-suite:

aa.NumMayAlias  |   3072005 |  3072016
aa.NumMustAlias |    337858 |   337854
aa.NumNoAlias   |  13255345 | 13255349

The motivation for the change is to expose the MayBeCrossIteration flag to AA users, which will allow fixing miscompiles related to incorrect handling of cross-iteration AA queries.

Diff Detail

Event Timeline

nikic created this revision.Oct 18 2022, 7:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2022, 7:18 AM
nikic requested review of this revision.Oct 18 2022, 7:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 18 2022, 7:18 AM
reames accepted this revision.Oct 26 2022, 9:17 AM

LGTM

I'm surprised at the lack of precision loss here, but well, the numbers speak for themselves.

This revision is now accepted and ready to land.Oct 26 2022, 9:17 AM
This revision was automatically updated to reflect the committed changes.