diff mbox

[gccgo] Compile libgo with -minline-all-stringops

Message ID mcrr5iijxxx.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 1, 2010, 12:54 p.m. UTC
One common reason that routines libgo to force a stack split is that
they call a builtin function like memcpy.  This patch compiles libgo
with -minline-all-stringops when available, to force those functions to
be expanded inline on x86.  That will sometimes be slower, but it will
never be as slow as a forced stack split.  Committed to gccgo branch.

Ian
diff mbox

Patch

diff -r 2c0e462b0002 libgo/Makefile.am
--- a/libgo/Makefile.am	Sun Aug 01 05:27:18 2010 -0700
+++ b/libgo/Makefile.am	Sun Aug 01 05:40:01 2010 -0700
@@ -35,6 +35,7 @@ 
 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
 
 AM_CFLAGS = -fexceptions -fplan9-extensions $(SPLIT_STACK) $(WARN_CFLAGS) \
+	$(STRINGOPS_FLAG) \
 	-I $(srcdir)/../gcc -I $(MULTIBUILDTOP)../../gcc/include
 
 if USING_SPLIT_STACK
@@ -1155,7 +1156,8 @@ 
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 
 GOFLAGS = $(CFLAGS)
-GOCOMPILE = $(GCCGO) $(DEFAULT_INCLUDES) $(INCLUDES) $(GOFLAGS)
+AM_GOFLAGS = $(STRINGOPS_FLAG)
+GOCOMPILE = $(GCCGO) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_GOFLAGS) $(GOFLAGS)
 
 LTGOCOMPILE = $(LIBTOOL) --tag GO --mode=compile $(GCCGO) $(INCLUDES) \
 	$(AM_GOFLAGS) $(GOFLAGS)
diff -r 2c0e462b0002 libgo/configure.ac
--- a/libgo/configure.ac	Sun Aug 01 05:27:18 2010 -0700
+++ b/libgo/configure.ac	Sun Aug 01 05:40:01 2010 -0700
@@ -195,6 +195,22 @@ 
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 AC_CHECK_FUNCS(srandom random strsignal)
 
+dnl For x86 we want to use the -minline-all-stringops option to avoid
+dnl forcing a stack split when calling memcpy and friends.
+AC_CACHE_CHECK([whether compiler supports -minline-all-stringops],
+[ac_cv_libgo_compiler_supports_inline_all_stringops],
+[CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -minline-all-stringops"
+AC_COMPILE_IFELSE([int i;],
+[ac_cv_libgo_compiler_supports_inline_all_stringops=yes],
+[ac_cv_libgo_compiler_supports_inline_all_stringops=no])
+CFLAGS=$CFLAGS_hold])
+STRINGOPS_FLAG=
+if test "$ac_cv_libgo_compiler_supports_inline_all_stringops" = yes; then
+  STRINGOPS_FLAG=-minline-all-stringops
+fi
+AC_SUBST(STRINGOPS_FLAG)
+
 CFLAGS_hold=$CFLAGS
 CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
 AC_CHECK_TYPES(off64_t)