diff mbox

Limit alignment on error_mark_node variable

Message ID 20150708153211.GA14935@intel.com
State New
Headers show

Commit Message

H.J. Lu July 8, 2015, 3:32 p.m. UTC
There is no need to try different alignment on variable of
error_mark_node.

OK for trunk if there is no regression?

Thanks.

H.J.
--
gcc/

	PR target/66810
	* varasm.c (align_variable): Don't try different alignment on
	variable of error_mark_node.

gcc/testsuite/

	PR target/66810
	* gcc.target/i386/pr66810.c: New test.
---
 gcc/testsuite/gcc.target/i386/pr66810.c | 10 ++++++++++
 gcc/varasm.c                            |  3 ++-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr66810.c

Comments

Richard Biener July 9, 2015, 8:16 a.m. UTC | #1
On Wed, Jul 8, 2015 at 5:32 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> There is no need to try different alignment on variable of
> error_mark_node.
>
> OK for trunk if there is no regression?

Can't we avoid calling align_variable on error_mark_node type decls
completely?  That is, punt earlier when we try to emit it.

> Thanks.
>
> H.J.
> --
> gcc/
>
>         PR target/66810
>         * varasm.c (align_variable): Don't try different alignment on
>         variable of error_mark_node.
>
> gcc/testsuite/
>
>         PR target/66810
>         * gcc.target/i386/pr66810.c: New test.
> ---
>  gcc/testsuite/gcc.target/i386/pr66810.c | 10 ++++++++++
>  gcc/varasm.c                            |  3 ++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr66810.c
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr66810.c b/gcc/testsuite/gcc.target/i386/pr66810.c
> new file mode 100644
> index 0000000..4778b37
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr66810.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile { target ia32 } } */
> +/* { dg-options "-mno-sse -mno-mmx -miamcu" } */
> +
> +int vv;
> +
> +void
> +i (void)
> +{
> +  static int a[vv]; /* { dg-error "storage size" } */
> +}
> diff --git a/gcc/varasm.c b/gcc/varasm.c
> index b69b3a3..be33cb4 100644
> --- a/gcc/varasm.c
> +++ b/gcc/varasm.c
> @@ -1016,7 +1016,8 @@ align_variable (tree decl, bool dont_output_data)
>        align = MAX_OFILE_ALIGNMENT;
>      }
>
> -  if (! DECL_USER_ALIGN (decl))
> +  /* Don't try different alignment for error_mark_node.  */
> +  if (! DECL_USER_ALIGN (decl) && TREE_TYPE (decl) != error_mark_node)
>      {
>  #ifdef DATA_ABI_ALIGNMENT
>        unsigned int data_abi_align
> --
> 2.4.3
>
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.target/i386/pr66810.c b/gcc/testsuite/gcc.target/i386/pr66810.c
new file mode 100644
index 0000000..4778b37
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr66810.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-mno-sse -mno-mmx -miamcu" } */
+
+int vv;
+
+void
+i (void)
+{
+  static int a[vv]; /* { dg-error "storage size" } */
+}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index b69b3a3..be33cb4 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1016,7 +1016,8 @@  align_variable (tree decl, bool dont_output_data)
       align = MAX_OFILE_ALIGNMENT;
     }
 
-  if (! DECL_USER_ALIGN (decl))
+  /* Don't try different alignment for error_mark_node.  */
+  if (! DECL_USER_ALIGN (decl) && TREE_TYPE (decl) != error_mark_node)
     {
 #ifdef DATA_ABI_ALIGNMENT
       unsigned int data_abi_align