This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: auto-detected pure functions are ``inlined'' in spire of noinline


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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]