This is an archive of the discontinued LLVM Phabricator instance.

[llvm langref] inaccessiblemem implies nosync
Needs ReviewPublic

Authored by hiraditya on Aug 11 2023, 3:56 PM.

Diff Detail

Unit TestsFailed

Event Timeline

hiraditya created this revision.Aug 11 2023, 3:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 3:56 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
hiraditya requested review of this revision.Aug 11 2023, 3:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2023, 3:56 PM
nikic edited reviewers, added: efriedma; removed: eli.friedman.Aug 12 2023, 12:05 AM

inaccessiblemem takes an access "kinds" which changes the behavior a lot. Is nosync implied by inaccessiblemem: none, or by inaccessiblemem: write, or both?

That said, we have nosync, people should just add it. This patch would cause all places that interpret nosync to also look for other things, which is not helpful at all.
If you want this behavior w/o the complex semantic, add nosync to all intrinsics and known functions we have right now. The rest is deduction.

nikic added a subscriber: nikic.Aug 14 2023, 1:31 AM

TBH I find the semantics of nosync to be unclear to the point of uselessness, and I'm not sure whether this patch helps clarify them any.

I think the two clarifications to nosync that would help are:

  • The memory effects of a synchronizing operation include all memory effects that the synchronization can make visible. For example, a synchronizing operation that can make previous writes to a location visible must have a write memory effect for that location.
  • A synchronizing operation that imposes an ordering constraint with other synchronizing operations must perform a read and write to inaccessible memory.

I think this matches how LLVM models synchronization, but I was never able to get really satisfactory answer to this.