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

inliner is broken



>Submitter-Id:	net
>Originator:	Dennis Haney
>Organization:	
>Confidential:	no
>Synopsis:	inliner is broken
>Severity:	non-critical
>Priority:	medium
>Category:	optimization
>Class:		sw-bug
>Release:	3.3 (Debian) (Debian testing/unstable)
>Environment:
System: Linux spiker 2.4.20-1-686 #1 Sat Mar 22 13:16:21 EST 2003 i686 GNU/Linux
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i386-linux
>Description:
	I'm getting some very wierd behaviour from the inliner. Functions that should be cost-free to inline are not inlined, even if they are marked with __attribute__((always_inline)).

	Example:

	static inline void TELL(const char *fmt, ...) __attribute__((format(printf,1,2),always_inline));
	static inline void TELL(const char *fmt, ...) {va_list ap;va_start(ap,fmt);vsyslog(LOG_NOTICE,_(fmt),ap);va_end(ap);}
	
	Even with the most modest optimizer, the inlining of this function should be costfree, simply reduced to a call to vsyslog.

	Another example:

	#define unlikely(exp) __builtin_expect((exp),0)
	static inline void DBG1(const char *fmt, ...) __attribute__((format(printf,1,2),always_inline));
	static inline void DBG1(const char *fmt, ...) {if(unlikely(debug >= 1)){va_list ap;va_start(ap,fmt);vsyslog(LOG_DEBUG,_(fmt),ap);va_end(ap);}}
	
	The cost of not inlining this function is bigger than inlining it, because of the overhead of a functioncall simple to return in most cases.

	Third, functions that are only used once are not inlined simply on the basis of larger code size. But if they are only used one place, how can the code get any smaller from not inlining?
	
>How-To-Repeat:
	create some large functions that use the above and turn on -Winline and see that it does certainly not do as you would expect.
>Fix:
	none known.



Reply to: