Excluded functions with cc65 inline assembler from optimization.

The cc65 documentation: "Note: Inline assembler statements are subject to all optimizations done by the compiler. There is currently no way to protect an inline assembler statement from being moved or removed completely by the optimizer. If in doubt, check the generated assembler output, or disable optimizations."

Unfortunately we learned recently the hard way that this is by no means no theoretical concern. In fact the cc65 optimizer removed several asm statements from contiki-cc65/uip/uip_arch.c.

Fortunately the cc65 compiler (starting with mid-July 2004 snapshots) now understands an optimization pragma which allows to control optimization on a per-function level.

The pragma was inserted into the cc65 specific codebase without macro encapsulation or #ifdef because:

a) Older cc65 versions just issue an warning on the pragma - which makes perfectly sense as one might want to check the generated code in question manually.

b) The current cc65 version needs the pragma as a hint to generate correct code.

c) Future cc65 versions will probably exclude functions containing inline assembler from optimization automatically thus turning the pragma unnecessary - but still it doesn't hurt.
2 files changed
tree: 8fbeb92aef2cd7417c09c9584e1b59352175d6a9
  1. contiki-plus4/