This is the mail archive of the mailing list for the GCC 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, GCC 4.7] Backport fix for PR tree-optimization/53708

I'm hitting the same bug as in PR53708 when compiling GLIBC's dlfcn.c when
vectorization is enabled on powerpc64-linux.  A reduced test case is:

bergner@bns:~/gcc/BUGS> cat foo.i 
static void (*const init_array []) (void)
  __attribute__ ((section (".init_array"), aligned (sizeof (void *)), used))
= { 0 };

bergner@bns:~/gcc/BUGS> /home/bergner/gcc/build/gcc-fsf-4_7-base/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-4_7-base/gcc -S -m64 -O3 -maltivec foo.i -o

bergner@bns:~/gcc/BUGS> /home/bergner/gcc/build/gcc-fsf-4_7-pr53708/gcc/xgcc
-B/home/bergner/gcc/build/gcc-fsf-4_7-pr53708/gcc -S -m64 -O3 -maltivec foo.i
-o good.s

bergner@bns:~/gcc/BUGS> diff -u bad.s good.s 
--- bad.s    2012-10-30 10:41:15.000000000 -0500
+++ good.s    2012-10-30 10:41:23.000000000 -0500
@@ -2,7 +2,7 @@
     .section    ".toc","aw"
     .section    ".text"
     .section    .init_array,"a"
-    .align 4
+    .align 3
     .type    init_array, @object
     .size    init_array, 8

The above is bad, because the extra alignment causes the linker to add some
null padding to the init_array and the loader isn't expecting that and ends
up segv'ing.  I'd like to backport Richard's patch below to the 4.7 branch.
The patch bootstrapped and regtested on powerpc64-linux with no regressions.

Is it ok for the 4.7 branch?


	Backport from mainline
	2012-06-19  Richard Guenther  <>

	PR tree-optimization/53708
	* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Preserve
	user-supplied alignment and alignment of decls with the used
Index: gcc/tree-vect-data-refs.c
--- gcc/tree-vect-data-refs.c	(revision 192988)
+++ gcc/tree-vect-data-refs.c	(working copy)
@@ -4574,6 +4574,12 @@
   if (TREE_ASM_WRITTEN (decl))
     return false;
+  /* Do not override explicit alignment set by the user or the alignment
+     as specified by the ABI when the used attribute is set.  */
+  if (DECL_USER_ALIGN (decl)
+      || DECL_PRESERVE_P (decl))
+    return false;
   if (TREE_STATIC (decl))
     return (alignment <= MAX_OFILE_ALIGNMENT);

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