[LLVMdev] volatiles (was comparison of correctness of llvm and gcc)

Duncan Sands baldrick at free.fr
Wed Jul 30 04:47:04 PDT 2008


Hi John,

> We currently check that every byte of a volatile is accessed the same 
> number of times, and that this number doesn't change across optimization 
> levels.
> 
> If LLVM wants to make stronger guarantees that's great, I suspect this is 
> not hard to all to check.  Can you provide a list of types that should be 
> atomic for the x86 target?  For example would we expect a struct of size 4 
> to be atomically accessed?  How about pointers?  Bitfields?  Actually I 
> think the interaction of volatile and bitfields is murky so maybe we don't 
> want to go there.

on x86-32, 8, 16 and 32 bit integer reads and writes should be atomic, as
should be float and double read and writes (most likely long double too,
but I don't know).  Structs with one field should be read and written
atomically if the field is one of the above types [I'm talking about when
you read/write the entire struct; likewise for arrays with one element.
Note: the reads and writes need to be marked volatile, otherwise the compiler
feels no obligation to keep them atomic.

Best wishes,

Duncan.



More information about the llvm-dev mailing list