This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: auto-detected pure functions are ``inlined'' in spire of noinline
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 06 Dec 2003 14:44:01 -0800
- Subject: Re: auto-detected pure functions are ``inlined'' in spire of noinline
- References: <or4qwehh9v.fsf@livre.redhat.lsd.ic.unicamp.br>
Alexandre Oliva <aoliva@redhat.com> writes:
> Aren't you surprised that, when you compile code like this:
>
> void foo() __attribute__((__noinline__));
> void f() { foo(); }
> void foo() {}
>
> the code output for f() does not call foo()?
>
> Haven't you ever spent some time staring at the function inlining code
> just to find out that it wasn't inlining, after all, but rather the
> fact that foo() was auto-detected pure, and so the call was replaced
> with mere evaluation of its arguments, i.e., nothing at all?
...
> (i) adjust the docs of attribute noinline so as to mention this case,
> such that it is not surprising to those who learn about noinline in
> the docs and then don't understand why it's not working, or
>
> (ii) arrange for attribute noinline to disable the code that
> auto-detects the purity/constness of functions.
I think if you choose (ii), it would be better to rename the
attribute, since 'noinline' will become a somewhat misleading name. I
suggest 'volatile', since I think that's the behaviour you really
want.
--
- Geoffrey Keating <geoffk@geoffk.org>