This is an archive of the discontinued LLVM Phabricator instance.

[nofree] Only synchronization with release ordering breaks nofree
Needs ReviewPublic

Authored by nhaehnle on May 11 2021, 5:20 PM.

Details

Summary

With D101701, a function can no longer be nofree if it causes
caller-visible memory to be freed indirectly by another thread. The
checks introduced there are equivalent to the checks for nosync.
This change tightens those checks: only an atomic operation with release
(or higher) ordering can break the guarantee made by nofree. (Volatile
memory operations are still treated conservatively.)

A correctness argument is as follows. If a memory object is
dereferenceable at point A and freed at point B, then A must
happen-before B (otherwise, there is undefined behavior). If points A
and B are on different threads, then the only way that such a
happens-before relation can be introduced is if there is a release (or
stronger) ordering operation that "happens between" A and B on the
thread that executes A.

Diff Detail

Event Timeline

nhaehnle created this revision.May 11 2021, 5:20 PM
nhaehnle requested review of this revision.May 11 2021, 5:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2021, 5:20 PM
Herald added a subscriber: bbn. · View Herald Transcript

Just for the record, I am not going to review this until we've settled on semantics for nofree over in https://reviews.llvm.org/D101701. Once that's done, I'll take a pass here. (You may need to ping me; this is likely to fall off my active list.)

reames resigned from this revision.Nov 30 2021, 9:58 AM
ormris removed a subscriber: ormris.Jan 24 2022, 11:15 AM