This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Limit alignment increase for TLS variables (was Re: [gomp] Avoid -Wl,-z,nodlopen (PR libgomp/28482))
On Wed, May 02, 2007 at 11:47:11AM -0700, Richard Henderson wrote:
> On Wed, May 02, 2007 at 02:06:03PM -0400, Jakub Jelinek wrote:
> > Do you think this can be changed in generic code (i.e. DECL_THREAD_LOCAL_P
> > -> don't use DATA_ALIGNMENT)?
>
> Probably. I can't think of any reason not to.
Here is a patch that allows only limited alignment growth, I think
BITS_PER_WORD is a usable trade-off between performance and space
occupied in TLS block.
Regtested on x86_64-linux, ok for trunk?
2007-05-03 Jakub Jelinek <jakub@redhat.com>
* varasm.c (align_variable): Don't increase alignment for
DECL_THREAD_LOCAL_P variables above BITS_PER_WORD through
DATA_ALIGNMENT or CONSTANT_ALIGNMENT.
--- gcc/varasm.c.jj 2007-04-14 14:55:25.000000000 +0200
+++ gcc/varasm.c 2007-05-03 11:23:56.000000000 +0200
@@ -1097,11 +1097,22 @@ align_variable (tree decl, bool dont_out
if (! DECL_USER_ALIGN (decl))
{
#ifdef DATA_ALIGNMENT
- align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
+ unsigned int data_align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
+ /* Don't increase alignment too much for TLS variables - TLS space
+ is too precious. */
+ if (! DECL_THREAD_LOCAL_P (decl) || data_align <= BITS_PER_WORD)
+ align = data_align;
#endif
#ifdef CONSTANT_ALIGNMENT
if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
- align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
+ {
+ unsigned int const_align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl),
+ align);
+ /* Don't increase alignment too much for TLS variables - TLS space
+ is too precious. */
+ if (! DECL_THREAD_LOCAL_P (decl) || const_align <= BITS_PER_WORD)
+ align = const_align;
+ }
#endif
}
Jakub