systematic miscompilation of volatile accesses

Skip to first unread message

John Regehr

Apr 28, 2008, 11:30:55 PM4/28/08
I just wanted to plug a study that a colleague and I recently
completed where we found that it is not uncommon for optimizing
compilers to generate incorrect code for accessing volatile objects.
This is, I think, no big surprise since volatiles are not that easy to
test and generating correct code entails getting a lot of special
cases right.

Chris Thomasson

Apr 29, 2008, 12:29:59 AM4/29/08
"John Regehr" <> wrote in message

Sounds like they are using a simple hack in the form of external function
calls. Well, link-time optimizations aside, this should work. Read the brief
introduction to this matter:

" The lock-free queue does not rely on any "atomic operations". It uses
simple loads and stores guarded with memory barriers. All of its
"critical-sequences" are contained in externally assembled functions:

in order to prevent a rouge C compiler from reordering anything that would
corrupt the data-structure". Link-time optimizations can potentially break

Reply all
Reply to author
0 new messages