Compiler is too ####### clever!

I have a short routine (lets call it A) that I want to call from two different places. In the normal way it is called by another short routine (B) that checks if it is time to start. The other use is for A to be called 2048 times by a third routine (C) in order to determine how many microseconds it takes for routing A to run.

In theory this is all very straightforward except that ...

The compiler, in its wisdom has merged A into B and has separately merged A into C and, unfortunately the two versions of A are not identical at the level of assembler code so the measured timings won't be correct.

Has anyone come across this problem and does anyone know how to make the compiler simply call a single copy of routine A from two different places?

The way the compiler is doing things the code is longer (in the interest of speed I suppose). Perhaps if there is a switch to make it give priority to small size that would solve the problem?

...R

Sounds like it "inlined" A? Try

void __attribute__ ((noinline)) A(void) {}

Thank you, Jack. That works like a dream.

In the land of the blind, the one-eyed man is king!

Though I'm sure you have many eyes :)

By the way I had to alter your example to "attribute ((noinline)) A(void) {}"

...R

No, Jack Christensen only has one i...