i386.c has int ix86_data_alignment (tree type, int align, bool opt) But "align" passed down is unsigned.
(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.
(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]$
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
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
Fixed.