optmization barrier?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

optmization barrier?

2,047 Views
regehr
Contributor I
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

  _ReadWriteBarrier


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.

Thanks!

Labels (1)
0 Kudos
3 Replies

301 Views
J2MEJediMaster
Specialist I
Start with studying the CodeWarrior Development Studio ColdFire Architectures Edition Build Tools Reference manual. It should be part of the documentation that came with the ColdFire installation. This manual describes the various tools in some detail, and the optimizations the compiler performs. It also describes the various pragmas used to control code optimizations and code generation. You might be able to bracket your critical code sections with pragmas that manage optimization control.

HTH.

---Tom
0 Kudos

301 Views
regehr
Contributor I
Tom-

I have studied this manual (though not in great detail) and while I saw plenty of pragmas for controlling optimizations for a region of code, I saw nothing that appeared to give the semantics that I described.

The reason that I'm asking for this is that correct and portable lock primitives cannot be built without proper optimization barriers.  I'm not saying that CW at present generates incorrect object code, but rather that "future proof" synchronization constructs cannot be built without some sort of code/value motion guarantee provided by the compiler.  Volatile alone does not provide sufficient guarantees (at least in C89).

If, after looking at the manual more closely, I cannot find what I want, would it be reasonable to file a feature request with the compiler team?

Thanks.

0 Kudos

301 Views
J2MEJediMaster
Specialist I
Good luck with looking at those pragmas. Maybe you'll find one that works. By all means file a feature request with the compiler team if you want to. We do value input on our tools, and we'd prefer to add features that the customer wants.

---Tom


0 Kudos