This is an archive of the discontinued LLVM Phabricator instance.

Polish atomic pointers
ClosedPublic

Authored by jfb on Dec 14 2015, 4:21 PM.

Details

Summary

I didn't realize that we already allowed atomic load/store of pointers,
it was added in 2012 by r162146. This patch updates the documentation
and tightens the verifier by using DataLayout to make sure that the
stored size is byte-sized and power-of-two. DataLayout is also used for
integers, and while I'm here I updated the corresponding code for
cmpxchg and rmw.

See the following discussion for context and upcoming changes to
add floating-point and vector atomics:

https://groups.google.com/forum/#!topic/llvm-dev/Nh0P_E3CRoo/discussion

Diff Detail

Event Timeline

jfb updated this revision to Diff 42798.Dec 14 2015, 4:21 PM
jfb retitled this revision from to Polish atomic pointers.
jfb updated this object.
jfb added a reviewer: reames.
jfb added a subscriber: llvm-commits.
reames edited edge metadata.Dec 14 2015, 5:29 PM

Please hold off on landing this until my floating point change has landed. This will create merge conflicts and is relatively low value. I can even combine the doc changes into my final commit if you'd rather.

lib/IR/Verifier.cpp
86

I would prefer you not add a new member variable for something easily accessible from the module.

2760

Without having dug in too much, this doesn't look right. I believe the store size is rounded up to the next byte before being returned, which would invalidate the power of two check.

2785–2790

Rather than duplicate all of this code, please extract a helper function which is called from each place. checkTypeAtomicity or something?

jfb updated this revision to Diff 43162.Dec 17 2015, 11:30 AM
jfb marked an inline comment as done.
jfb edited edge metadata.

Rebase, address review comments.

jfb marked 2 inline comments as done.Dec 17 2015, 11:31 AM

Comments addressed, PTAL.

lib/IR/Verifier.cpp
2760

Right you are. Fixed.

reames accepted this revision.Dec 17 2015, 2:07 PM
reames edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 17 2015, 2:07 PM
This revision was automatically updated to reflect the committed changes.
jfb marked an inline comment as done.