asm volatile("":::"memory) uncertainty.
Andrew Haley
aph@redhat.com
Tue May 10 09:24:00 GMT 2016
On 09/05/16 22:40, Tom Udale wrote:
> My confusion is whether or not the memory cobberer prevents movement of
> statements in addition to flushing any values that may be in registers
> before the compiler_barrier() line. i.e. it is unclear if there is any
> control over what statements the memory being flushed is attached to (if
> this makes any sense).
Memory barriers only prevent code which accesses memory from being
moved.
It's not going to be easy to do what you're asking for in the
presence of optimization. GCC orders instruction generation by
dependency. I'd simply put all the code you want to time into a
separate function in a separate compilation unit and do this:
start = starttime(); foo(); end = endtime();
Alteratively, it might be possible to define asm inputs and outputs
so that your asm barriers depend on the statements you're trying
to measure.
Andrew.
More information about the Gcc-help
mailing list