[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Linux-ia64] gcc won't inline function returning struct?

	typedef struct {
		float re, im;
		int dummy;
	} complex;

I tried this, and it works.

>Since this is no longer an HFA would this kick the compiler into
>a mode where the code would at least work, all be it not in the most
>efficient manner?

Just to clarify, the code that gcc emits is correct.  The testcase can fail
only if the "extern inline" feature is misused.  I assumed that was the
case without explicitly mentioning it.  Thus my recommended solution would be
to stop using extern inline, or else use it correctly.  I can understand that
this might be inconvenient, and that you might want to keep the current
unsafe uses of extern inline.

extern inline means emit this function inline if you can, otherwise emit
nothing.  Since gcc makes no promise that it will inline any function, it
is inherently unsafe to put extern inline in a C file.  There is no guarantee
that it will work.

There are some programs that do this for functions that the IA-32 compiler
happens to inline, but which the IA-64 compiler does not happen to inline.
This always gets reported as an IA-64 gcc "bug", but really it isn't.  It
is programmer error; extern inline has been used incorrectly.

A correct use of extern inline is how glibc uses it.  It puts extern inline
in header files, and static functions in C files linked into libc/libm.
If gcc can inline the function, then you get the fast inline version from
the header file.  If gcc cannot inline the function, then you get the slow
static version from libc/libm.


Reply to: