diff mbox

Preserve user alignment on decls (PR middle-end/68960)

Message ID 20160105182557.GA18720@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 5, 2016, 6:25 p.m. UTC
Hi!

When a VAR_DECL is copied (e.g. for OpenMP/OpenACC privatization, or
when moving SESE region to another function), copy_var_decl only preserves
user alignment on types, but not on decls.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/68960
	* gimple-expr.c (copy_var_decl): If var has DECL_USER_ALIGN set, copy
	it and DECL_ALIGN too.

	* testsuite/libgomp.c/pr68960.c: New test.


	Jakub

Comments

Jeff Law Jan. 5, 2016, 6:28 p.m. UTC | #1
On 01/05/2016 11:25 AM, Jakub Jelinek wrote:
> Hi!
>
> When a VAR_DECL is copied (e.g. for OpenMP/OpenACC privatization, or
> when moving SESE region to another function), copy_var_decl only preserves
> user alignment on types, but not on decls.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2016-01-05  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR middle-end/68960
> 	* gimple-expr.c (copy_var_decl): If var has DECL_USER_ALIGN set, copy
> 	it and DECL_ALIGN too.
>
> 	* testsuite/libgomp.c/pr68960.c: New test.
OK for the trunk.

Jeff
diff mbox

Patch

--- gcc/gimple-expr.c.jj	2016-01-04 14:55:52.000000000 +0100
+++ gcc/gimple-expr.c	2016-01-05 16:21:53.831077722 +0100
@@ -375,6 +375,11 @@  copy_var_decl (tree var, tree name, tree
   TREE_USED (copy) = 1;
   DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
   DECL_ATTRIBUTES (copy) = DECL_ATTRIBUTES (var);
+  if (DECL_USER_ALIGN (var))
+    {
+      DECL_ALIGN (copy) = DECL_ALIGN (var);
+      DECL_USER_ALIGN (copy) = 1;
+    }
 
   return copy;
 }
--- libgomp/testsuite/libgomp.c/pr68960.c.jj	2016-01-05 16:26:34.957162544 +0100
+++ libgomp/testsuite/libgomp.c/pr68960.c	2016-01-05 16:30:11.000000000 +0100
@@ -0,0 +1,25 @@ 
+/* PR middle-end/68960 */
+/* { dg-do run } */
+
+int
+main ()
+{
+  int temp[257] __attribute__ ((aligned (256))) = { 0 };
+  #pragma omp parallel private (temp) num_threads (2)
+  {
+    int *p = &temp[0];
+    asm volatile ("" : "+g" (p));
+    if (((__UINTPTR_TYPE__) p) & 255)
+      __builtin_abort ();
+  }
+  #pragma omp parallel num_threads (2)
+  #pragma omp single
+  #pragma omp task firstprivate (temp)
+  {
+    int *p = &temp[0];
+    asm volatile ("" : "+g" (p));
+    if (((__UINTPTR_TYPE__) p) & 255)
+      __builtin_abort ();
+  }
+  return 0;
+}