asm volatile statement reordering

Andrew Haley aph@redhat.com
Tue Oct 17 12:27:00 GMT 2017


On 17/10/17 11:20, David Brown wrote:
> I don't want to forbid new optimisations in gcc - I am very happy to see
> steadily more optimisations, as are most embedded developers.  Better
> optimisations means we embedded developers can do more with less
> hardware - smaller code means cheaper chips, and faster code means lower
> power.
> 
> What I want is to be sure that I can use these optimisations without
> risking incorrect code.

Add exactly the dependencies you need, and GCC will honour them.

If you need foo() to execute after cpsid, create an explicit
dependency in foo().  You can, for example, tell GCC that cpsid writes
to a variable and then make foo() depend on that variable.  In this case,
pass status in to foo.

Memory clobbers are rather extreme, but they only affect those
variables which have their address taken.  If a variable is global, of
course, it is reachable from anywhere, but variables in local scope
aren't.

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the Gcc-help mailing list