How to stop gcc from not calling noinline functions

Mark Mitchell mark@codesourcery.com
Wed Feb 6 23:59:00 GMT 2008


Richard Guenther wrote:

> You can apart from the other suggestions also mark the function weak
> which will prevent both inlining and pure/const analysis.

How about just writing to a volatile variable from within the callee?

void f() __attribute__((noinline)) {
   volatile int i;
   i = 3;
}

void g() {
   f();
}

A valid GNU C compiler cannot eliminate the call to "f", as long as the 
call itself is reachable.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc mailing list