Bug 89261 - ix86_data_alignment has wrong argument type
Summary: ix86_data_alignment has wrong argument type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: 10.0
Assignee: Uroš Bizjak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-09 04:31 UTC by H.J. Lu
Modified: 2019-04-27 13:40 UTC (History)
1 user (show)

See Also:
Host:
Target: i386,x86-64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-02-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2019-02-09 04:31:24 UTC
i386.c has

int
ix86_data_alignment (tree type, int align, bool opt)

But "align" passed down is unsigned.
Comment 1 Uroš Bizjak 2019-02-09 09:27:48 UTC
(In reply to H.J. Lu from comment #0)
> i386.c has
> 
> int
> ix86_data_alignment (tree type, int align, bool opt)
> 
> But "align" passed down is unsigned.

Where is the bug?

I don't think anybody passed negative alignment or alignment >= 2G.
Comment 2 H.J. Lu 2019-02-09 12:25:17 UTC
(In reply to Uroš Bizjak from comment #1)
> (In reply to H.J. Lu from comment #0)
> > i386.c has
> > 
> > int
> > ix86_data_alignment (tree type, int align, bool opt)
> > 
> > But "align" passed down is unsigned.
> 
> Where is the bug?
> 
> I don't think anybody passed negative alignment or alignment >= 2G.

This is a valid code:

[hjl@gnu-skx-1 gcc]$ cat /tmp/x.i
typedef double __v2df __attribute__ ((__vector_size__ (16), aligned(1 << 28)));
__v2df foo = { 1.0, 2.0 };
[hjl@gnu-skx-1 gcc]$ gcc -S /tmp/x.i
[hjl@gnu-skx-1 gcc]$ cat x.s
	.file	"x.i"
	.text
	.globl	foo
	.data
	.align 16   <<<<<<<<<<<< This is wrong.
	.type	foo, @object
	.size	foo, 16
foo:
	.long	0
	.long	1072693248
	.long	0
	.long	1073741824
	.ident	"GCC: (GNU) 8.2.1 20190109 (Red Hat 8.2.1-7)"
	.section	.note.GNU-stack,"",@progbits
[hjl@gnu-skx-1 gcc]$
Comment 3 Uroš Bizjak 2019-02-10 19:32:59 UTC
Following patch:

--cut here--
Index: config/i386/i386-protos.h
===================================================================
--- config/i386/i386-protos.h	(revision 268670)
+++ config/i386/i386-protos.h	(working copy)
@@ -207,7 +207,7 @@
 #endif	/* RTX_CODE  */
 
 #ifdef TREE_CODE
-extern int ix86_data_alignment (tree, int, bool);
+extern int ix86_data_alignment (tree, unsigned int, bool);
 extern unsigned int ix86_local_alignment (tree, machine_mode,
 					  unsigned int);
 extern unsigned int ix86_minimum_alignment (tree, machine_mode,
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 268670)
+++ config/i386/i386.c	(working copy)
@@ -29620,7 +29616,7 @@
    instead of that alignment to align the object.  */
 
 int
-ix86_data_alignment (tree type, int align, bool opt)
+ix86_data_alignment (tree type, unsigned int align, bool opt)
 {
   /* GCC 4.8 and earlier used to incorrectly assume this alignment even
      for symbols from other compilation units or symbols that don't need
--cut here--

fixes the testcase:

        .file   "align.c"
        .text
        .globl  foo
        .data
        .align 268435456
        .type   foo, @object
        .size   foo, 16
foo:
        .long   0
        .long   1072693248
        .long   0
        .long   1073741824
        .ident  "GCC: (GNU) 9.0.1 20190208 (experimental) [trunk revision 268670]"
        .section        .note.GNU-stack,"",@progbits
Comment 4 uros 2019-04-27 13:38:51 UTC
Author: uros
Date: Sat Apr 27 13:38:19 2019
New Revision: 270623

URL: https://gcc.gnu.org/viewcvs?rev=270623&root=gcc&view=rev
Log:
	PR target/89261
	* config/i386/i386-protos.h (ix86_data_alignment): Change
	the second argument type to unsigned int.
	* config/i386/i386.c (ix86_data_alignment): Change "align"
	argument type to unsigned int.

testsuite/ChangeLog:

	PR target/89261
	* gcc.target/i386/pr89261.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr89261.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386-protos.h
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Uroš Bizjak 2019-04-27 13:40:47 UTC
Fixed.