public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RTL for function marked "static inline" is not generated at -O0
@ 2012-05-27  5:10 Ayonam Ray
  2012-05-27  9:12 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: Ayonam Ray @ 2012-05-27  5:10 UTC (permalink / raw)
  To: gcc-help

Hi,

Any idea why even the RTL would not be generated for functions that
are marked "static inline" at -O0?

For a simple test case like this one:

static inline int foo(int a, int b);

int
bar(int p, short q)
{
  int a = p * q;
  int b = p/q;

  return foo(a, b);
}

static inline int
foo(int a, int b)
{
  return a - b;
}

The compiler doesn't generate the RTL for the function foo at -O0.
Since the function is not inlined at -O0, there is a call to foo() in
bar() and the function foo() does not exist in the assembly generated.

This apart, the following observations are made:

1) If the static keyword is removed, the test case works fine.
2) If the function definition of foo() is moved before the definition
of bar(), the test case works fine.
3) If the file is compiled at -O1 or -O2, the function gets inlined
and hence the test case again works fine.

Any suggestions on what might be happening?  I'm using gcc-4.1.2.
I've checked the flags_inline* variables and their values at runtime
seem to be in order.

Thanks and regards
Ayonam

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: RTL for function marked "static inline" is not generated at -O0
  2012-05-27  5:10 RTL for function marked "static inline" is not generated at -O0 Ayonam Ray
@ 2012-05-27  9:12 ` Andrew Haley
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Haley @ 2012-05-27  9:12 UTC (permalink / raw)
  To: gcc-help

On 05/27/2012 06:10 AM, Ayonam Ray wrote:
> The compiler doesn't generate the RTL for the function foo at -O0.
> Since the function is not inlined at -O0, there is a call to foo() in
> bar() and the function foo() does not exist in the assembly generated.

It works for me with gcc version 4.1.2 x86_64.

Andrew.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-27  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-27  5:10 RTL for function marked "static inline" is not generated at -O0 Ayonam Ray
2012-05-27  9:12 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).