This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: asm volatile("":::"memory) uncertainty.


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]