This is an archive of the discontinued LLVM Phabricator instance.

[CaptureTracking] Support atomicrmw and cmpxchg
ClosedPublic

Authored by reames on Feb 18 2016, 10:32 AM.

Details

Summary

These atomic operations are conceptually both a load and store from the same location. As such, we can treat them as the most conservative of those two components which in practice, means we can treat them like stores. An cmpxchg or atomicrmw captures the values, but not the locations accessed.

Note: We can probably be more aggressive about the comparison value in an cmpxhg since to have it be in memory, it must already be captured, but I figured it was better to avoid that for the moment.

Note 2: It turns out that since we don't actually support cmpxchg of pointer type, writing a negative test is impossible.

Diff Detail

Repository
rL LLVM

Event Timeline

reames updated this revision to Diff 48355.Feb 18 2016, 10:32 AM
reames retitled this revision from to [CaptureTracking] Support atomicrmw and cmpxchg.
reames updated this object.
reames added reviewers: jfb, sanjoy, nicholas.
reames added a subscriber: llvm-commits.
sanjoy accepted this revision.Feb 18 2016, 10:55 AM
sanjoy edited edge metadata.

lgtm

This revision is now accepted and ready to land.Feb 18 2016, 10:55 AM
jfb edited edge metadata.Feb 18 2016, 11:23 AM

lgtm

Interesting: the current code can't see through an inttoptr + cmpxchg which captures the pointer? It assumes it's captured as soon as the inttoptr occurs?

In D17400#356062, @jfb wrote:

Interesting: the current code can't see through an inttoptr + cmpxchg which captures the pointer? It assumes it's captured as soon as the inttoptr occurs?

Yes. Which is one of the many reasons we should just support cmpxchg on pointers directly. :)

This revision was automatically updated to reflect the committed changes.
jfb added a comment.Feb 18 2016, 11:28 AM
In D17400#356062, @jfb wrote:

Interesting: the current code can't see through an inttoptr + cmpxchg which captures the pointer? It assumes it's captured as soon as the inttoptr occurs?

Yes. Which is one of the many reasons we should just support cmpxchg on pointers directly. :)

You've got my support :-)

FYI, since we didn't seem to have one, I filed a bug for support pointer typed cmpxchgs: https://llvm.org/bugs/show_bug.cgi?id=26668.