This is the mail archive of the
mailing list for the GCC project.
Re: asm volatile("":::"memory) uncertainty.
- From: Andrew Haley <aph at redhat dot com>
- To: Tom Udale <tom at ionoptix dot com>, gcc-help at gcc dot gnu dot org
- Date: Tue, 10 May 2016 10:24:14 +0100
- Subject: Re: asm volatile("":::"memory) uncertainty.
- Authentication-results: sourceware.org; auth=none
- References: <f3141159-2f2a-6317-8dd6-da0aa64eca14 at ionoptix dot com>
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
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