This is an archive of the discontinued LLVM Phabricator instance.

[ObjC][ARC] Fix non-deterministic behavior in ProvenanceAnalysis
ClosedPublic

Authored by ahatanak on May 10 2023, 1:22 PM.

Details

Summary

Stop reordering the pointers passed in ProvenanceAnalysis::related based on their values. That was causing non-determinism as the call to relatedCheck(A, B) isn't guaranteed to return the same result as relatedCheck(B, A).

Revert the following three commits (except the original test case in related-check.ll):

665e47777df17db406c698d57b4f3c28d67c432e
295861514e0d1e48df2918b630dd692ac27ee0de
d877e3fe71676b0ff10410d80456b35cdd5bf796

These changes shouldn't be necessary once the call to std::swap is removed.

Diff Detail

Event Timeline

ahatanak created this revision.May 10 2023, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2023, 1:22 PM
ahatanak requested review of this revision.May 10 2023, 1:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2023, 1:22 PM

The downside of removing the call to std::swap is that we can no longer reuse the result of related(A, B) when related(B, A) is called, but probably that doesn't have a large impact on compile time.

We need this change because we found another case where assert(relatedCheck(B, A) == Result) in ProvenanceAnalysis::related was failing. The assertion was failing because BasicAAResult::alias(A, B)and BasicAAResult::alias(B, A) were giving different answers.

akyrtzi added inline comments.May 10 2023, 1:39 PM
llvm/test/Transforms/ObjCARC/related-check.ll
120

Does this need to be removed? I assume it was a non-deterministic test case.

ahatanak added inline comments.May 10 2023, 1:46 PM
llvm/test/Transforms/ObjCARC/related-check.ll
120

We can probably leave those test cases there, but they weren't in the original test case committed in https://reviews.llvm.org/D135376. The test cases were added in the two patches I committed later and were added only to check the assertion assert(relatedCheck(B, A) == Result) was no longer failing.

akyrtzi accepted this revision.May 10 2023, 1:56 PM
This revision is now accepted and ready to land.May 10 2023, 1:56 PM