This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

[PATCH] Fixes tree-loop-distribute-patterns issues


Hi all,

This patch fixes the build on some configuration with GCC 4.8 plus -O3.
The issue is at this optimization level the compiler adds the optimization
level -ftree-loop-distribute-patterns as default and it may causes recursive
calls on memset/memmove builds.

This patch just disable the optimization when required. I tested with
build using -mcpu=powerpc and -mcpu=powerpc64 (which ending using
string/memset.c for the rtld-memset.os) with both GCC 4.4 (which does
not support the optimization) and GCC 4.8.

Any tips, comments, advices?

---

2013-06-18  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* include/libc-symbols.h (ATTRIBUTE_NO_TREE_LOOP_DISTRIBUTE_PATTERNS):
	Define to disable loop transformation to library calls.
	* string/memmove.c (MEMMOVE): Disable loop transformation to avoid
	recursive call.
	* string/memset.c (memset): Likewise.

--

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index f043ce0..6717e7a 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -782,4 +782,11 @@ for linking")
 #define libc_ifunc_hidden_def(name) \
   libc_ifunc_hidden_def1 (__GI_##name, name)
 
+#if 4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)
+# define ATTRIBUTE_NO_TREE_LOOP_DISTRIBUTE_PATTERNS \
+  __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
+#else
+# define ATTRIBUTE_NO_TREE_LOOP_DISTRIBUTE_PATTERNS
+#endif
+
 #endif /* libc-symbols.h */
diff --git a/string/memmove.c b/string/memmove.c
index 9dcd2f1..6da0db5 100644
--- a/string/memmove.c
+++ b/string/memmove.c
@@ -41,6 +41,10 @@
 #endif
 
 rettype
+MEMMOVE (a1const void *a1, a2const void *a2, size_t len)
+  ATTRIBUTE_NO_TREE_LOOP_DISTRIBUTE_PATTERNS;
+
+rettype
 MEMMOVE (a1, a2, len)
      a1const void *a1;
      a2const void *a2;
diff --git a/string/memset.c b/string/memset.c
index 868be53..db63ebb 100644
--- a/string/memset.c
+++ b/string/memset.c
@@ -21,6 +21,10 @@
 #undef memset
 
 void *
+memset (void *dstpp, int c, size_t len) 
+  ATTRIBUTE_NO_TREE_LOOP_DISTRIBUTE_PATTERNS;
+
+void *
 memset (dstpp, c, len)
      void *dstpp;
      int c;


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