This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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] Help gcc with inlining/not inlining a little bit


Hi!

GCC inliner needs to be improved, but in the mean time we can help
it a little bit.

2003-01-30  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-reloc.c (CHECK_STATIC_TLS): Move _dl_signal_error...
	(allocate_static_tls): ...here.  Add __attribute_noinline__.
	Don't return on failure.
	(_dl_reloc_bad_type): Add __attribute_noinline__.
	* elf/do-rel.h (elf_dynamic_do_rel): Add
	__attribute__((always_inline)).
	* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
	elf_machine_rel_relative, elf_machine_rela_relative, 
	elf_machine_lazy_rel): Add prototypes with
	__attribute__((always_inline)).

--- libc/elf/dl-reloc.c.jj	2003-01-30 05:06:29.000000000 -0500
+++ libc/elf/dl-reloc.c	2003-01-30 07:28:11.000000000 -0500
@@ -39,9 +39,9 @@
 /* We are trying to perform a static TLS relocation in MAP, but it was
    dynamically loaded.  This can only work if there is enough surplus in
    the static TLS area already allocated for each running thread.  If this
-   object's TLS segment is too big to fit, we return false.  If it fits,
-   we set MAP->l_tls_offset and return true.  */
-static bool
+   object's TLS segment is too big to fit, we fail.  If it fits,
+   we set MAP->l_tls_offset and return.  */
+static void __attribute_noinline__
 allocate_static_tls (struct link_map *map)
 {
   size_t offset = roundup (GL(dl_tls_static_used), map->l_tls_align);
@@ -54,10 +54,13 @@ allocate_static_tls (struct link_map *ma
 #  error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
 # endif
       > GL(dl_tls_static_size))
-    return false;
+    {
+      const char *errstring = N_("\
+shared object cannot be dlopen()ed: static TLS memory too small");
+      INTUSE(_dl_signal_error) (0, (map)->l_name, NULL, errstring);
+    }
   map->l_tls_offset = offset;
   GL(dl_tls_static_used) = offset + map->l_tls_blocksize;
-  return true;
 }
 #endif
 
@@ -197,13 +200,8 @@ _dl_relocate_object (struct link_map *l,
        intended to produce.  */
 #define CHECK_STATIC_TLS(map, sym_map)					      \
     do {								      \
-      if (__builtin_expect ((sym_map)->l_tls_offset == 0, 0)		      \
-	  && !allocate_static_tls (sym_map))				      \
-	{								      \
-	  errstring = N_("\
-shared object cannot be dlopen()ed: static TLS memory too small");	      \
-	  INTUSE(_dl_signal_error) (0, (map)->l_name, NULL, errstring);	      \
-	}								      \
+      if (__builtin_expect ((sym_map)->l_tls_offset == 0, 0))		      \
+	allocate_static_tls (sym_map);					      \
     } while (0)
 
 #include "dynamic-link.h"
@@ -256,7 +254,7 @@ INTDEF (_dl_relocate_object)
 
 
 void
-internal_function
+internal_function __attribute_noinline__
 _dl_reloc_bad_type (struct link_map *map, unsigned int type, int plt)
 {
   extern const char INTUSE(_itoa_lower_digits)[] attribute_hidden;
--- libc/elf/do-rel.h.jj	2003-01-30 05:06:29.000000000 -0500
+++ libc/elf/do-rel.h	2003-01-30 05:21:40.000000000 -0500
@@ -1,5 +1,5 @@
 /* Do relocations for ELF dynamic linking.
-   Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -49,7 +49,7 @@
    relocations; they should be set up to call _dl_runtime_resolve, rather
    than fully resolved now.  */
 
-static inline void
+static inline void __attribute__ ((always_inline))
 elf_dynamic_do_rel (struct link_map *map,
 		    ElfW(Addr) reladdr, ElfW(Addr) relsize,
 		    int lazy)
--- libc/elf/dynamic-link.h.jj	2002-09-28 10:59:14.000000000 -0400
+++ libc/elf/dynamic-link.h	2003-01-30 09:50:05.000000000 -0500
@@ -1,5 +1,5 @@
 /* Inline functions for dynamic linking.
-   Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -18,9 +18,36 @@
    02111-1307 USA.  */
 
 #include <elf.h>
-#include <dl-machine.h>
 #include <assert.h>
 
+#ifdef RESOLVE
+auto void __attribute__((always_inline))
+elf_machine_rel (struct link_map *map, const ElfW(Rel) *reloc,
+		 const ElfW(Sym) *sym, const struct r_found_version *version,
+		 ElfW(Addr) *const reloc_addr);
+auto void __attribute__((always_inline))
+elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
+		  const ElfW(Sym) *sym, const struct r_found_version *version,
+		  ElfW(Addr) *const reloc_addr);
+auto void __attribute__((always_inline))
+elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
+			  ElfW(Addr) *const reloc_addr);
+auto void __attribute__((always_inline))
+elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
+			   ElfW(Addr) *const reloc_addr);
+# if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
+auto void __attribute__((always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+		      ElfW(Addr) l_addr, const ElfW(Rel) *reloc);
+# else
+auto void __attribute__((always_inline))
+elf_machine_lazy_rel (struct link_map *map,
+		      ElfW(Addr) l_addr, const ElfW(Rela) *reloc);
+# endif
+#endif
+
+#include <dl-machine.h>
+
 #ifndef VERSYMIDX
 # define VERSYMIDX(sym)	(DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGIDX (sym))
 #endif

	Jakub


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