[Top][All Lists]

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

[avr-gcc-list] Avr-libc-user-manual: "Problems with reordering code"

From: Marcin Godlewski
Subject: [avr-gcc-list] Avr-libc-user-manual: "Problems with reordering code"
Date: Wed, 07 Dec 2016 00:42:05 +0100

Dear all,
I'm writing with reference to the following paragraph in avr libc manual:
It is stated there: "However, memory barrier works well in ensuring that all volatile accesses before and after the barrier occur in the given order with respect to the barrier. However, it does not ensure the compiler moving non-volatile-related statements across the barrier. Peter Dannegger provided a nice example of this effect:(...)". The text is followed by an example.
My understanding of the example is that what _probably_ made the operation being moved accross the barrier is that it involved only local data. This example doesn't show that any operations on global data can be moved accross the barrier. I think that the conclusion that a barrier prevents only operations on volatile data from being reordered accross the barrier is wrong. No operation on global data should be reordered accross the barrier, even on non-volatile data. But apparently, operations on local data can, which by the way makes some sense.
The definition of a barrier ensuring that "all volatile accesses before and after the barrier occur in the given order with respect to the barrier" doesn't make much sense as this is already guaranteed by the C language standard. Per standard, any operations on volatile variables must be evaluated according to the rules of the abstract machine.
Please let me know what is your view on the subject.
Best regards,Marcin Godlewski

reply via email to

[Prev in Thread] Current Thread [Next in Thread]