Re: Are arrays guaranteed to be affected by a "memory" clobber?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/12/2015 07:16 PM, Sebastian wrote:
> On Fri, 12 Jun 2015 09:36:54 +0100
> Andrew Haley <aph@xxxxxxxxxx> wrote:
> 
>> Eh?  The vriable access is a memory operation in [2].  It is
>> surrounded by the cli/sei, as required.  We cannot guarantee that
>> non-memory operations will not be reordered with memory barriers,
>> though.
> You mean the assignment to "ivar" (only that is "surrounded")?

Yes.  It is the only memory operation.

> Sorry that I wasn't clear about that. I meant the assignment to the local variable "val". It's moved across the barrier.

No it isn't.

> That's the whole point about the example.

No it's not.  The only thing moved across the barrier is the
division.  A memory op cannot  be moved across a memory barrier.

>>> Still the open question: Is access to array elements (or
>>> dereferencing a pointer) always considered a "memory operation",
>>
>> Yes.
> 
> So what's the difference between that variable "val" and my array elements, if I remove the "volatile"?

val is not moved across any barrier.

Here's the code:

00000112 <test2>:
 112:   bc 01           movw    r22, r24
 114:   f8 94           cli
 116:   8f ef           ldi     r24, 0xFF       ; 255
 118:   9f ef           ldi     r25, 0xFF       ; 255
 11a:   0e 94 96 00     call    0x12c   ; 0x12c <__udivmodhi4>
 11e:   70 93 01 02     sts     0x0201, r23
 122:   60 93 00 02     sts     0x0200, r22

The store to val is here ^

 126:   78 94           sei
 128:   08 95           ret


> - Is it that I have array elements / pointer dereferencings?
>   (I think so)
> - Or that it's a global variable?
>   (Probably not - shouldn't make a difference, at least when global but static)
> - Or is it because I'm not concerned about timing, just about correctness?
>   (Probably not)

Andrew.






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux