John Regehr

optmization barrier?

Discussion created by John Regehr on Sep 26, 2007
Latest reply on Sep 27, 2007 by Tom Thompson
I am trying to figure out if CodeWarrior's C compiler (in general, though it is ColdFire that I am most interested in) supports an optimization barrier. This is a code construct that prevents code motion (e.g. copy propagation) or cached values from passing the barrier in either direction. For example gcc has
  asm volatile ("" ::: "memory")
and Microsoft VC has


Note that I specifically do not wish to turn down the optimization level, write assembly, or abuse a function call boundary as an optimization barrier. Also I'm not talking about a hardware-level barrier here, I just want a way to suppress certain very specific optimizations that can break code.