public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix x86/56337 : 1<<28 alignment is broken
@ 2021-07-23 20:32 apinski
  2021-08-30 21:21 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: apinski @ 2021-07-23 20:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

From: Andrew Pinski <apinski@marvell.com>

The problem here is the x86_64 back-end uses a signed integer
for alignment and then divides by BITS_PER_UNIT so if we had
INT_MIN (which is what 1<<28*8 is), we would get the wrong result.

This fixes the problem by using unsigned for the argument to
x86_output_aligned_bss and x86_output_aligned_bss.

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	PR target/56337
	* config/i386/i386-protos.h (x86_output_aligned_bss):
	Change align argument to unsigned type.
	(x86_elf_aligned_decl_common): Likewise.
	* config/i386/i386.c (x86_elf_aligned_decl_common): Likewise.
	(x86_output_aligned_bss): Likewise.
---
 gcc/config/i386/i386-protos.h | 4 ++--
 gcc/config/i386/i386.c        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 07ac02aff69..fa1b0d0d787 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -325,9 +325,9 @@ struct ix86_address
 extern int ix86_decompose_address (rtx, struct ix86_address *);
 extern int memory_address_length (rtx, bool);
 extern void x86_output_aligned_bss (FILE *, tree, const char *,
-				    unsigned HOST_WIDE_INT, int);
+				    unsigned HOST_WIDE_INT, unsigned);
 extern void x86_elf_aligned_decl_common (FILE *, tree, const char *,
-					 unsigned HOST_WIDE_INT, int);
+					 unsigned HOST_WIDE_INT, unsigned);
 
 #ifdef RTX_CODE
 extern void ix86_fp_comparison_codes (enum rtx_code code, enum rtx_code *,
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 876a19f4c1f..f86d11dfb11 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -837,7 +837,7 @@ x86_64_elf_unique_section (tree decl, int reloc)
 void
 x86_elf_aligned_decl_common (FILE *file, tree decl,
 			const char *name, unsigned HOST_WIDE_INT size,
-			int align)
+			unsigned align)
 {
   if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
       && size > (unsigned int)ix86_section_threshold)
@@ -858,7 +858,7 @@ x86_elf_aligned_decl_common (FILE *file, tree decl,
 
 void
 x86_output_aligned_bss (FILE *file, tree decl, const char *name,
-		       	unsigned HOST_WIDE_INT size, int align)
+		       	unsigned HOST_WIDE_INT size, unsigned align)
 {
   if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
       && size > (unsigned int)ix86_section_threshold)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix x86/56337 : 1<<28 alignment is broken
  2021-07-23 20:32 [PATCH] Fix x86/56337 : 1<<28 alignment is broken apinski
@ 2021-08-30 21:21 ` Andrew Pinski
  2021-08-31  6:11   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2021-08-30 21:21 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Fri, Jul 23, 2021 at 1:33 PM apinski--- via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Andrew Pinski <apinski@marvell.com>
>
> The problem here is the x86_64 back-end uses a signed integer
> for alignment and then divides by BITS_PER_UNIT so if we had
> INT_MIN (which is what 1<<28*8 is), we would get the wrong result.
>
> This fixes the problem by using unsigned for the argument to
> x86_output_aligned_bss and x86_output_aligned_bss.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu.

Ping?

>
> gcc/ChangeLog:
>
>         PR target/56337
>         * config/i386/i386-protos.h (x86_output_aligned_bss):
>         Change align argument to unsigned type.
>         (x86_elf_aligned_decl_common): Likewise.
>         * config/i386/i386.c (x86_elf_aligned_decl_common): Likewise.
>         (x86_output_aligned_bss): Likewise.
> ---
>  gcc/config/i386/i386-protos.h | 4 ++--
>  gcc/config/i386/i386.c        | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
> index 07ac02aff69..fa1b0d0d787 100644
> --- a/gcc/config/i386/i386-protos.h
> +++ b/gcc/config/i386/i386-protos.h
> @@ -325,9 +325,9 @@ struct ix86_address
>  extern int ix86_decompose_address (rtx, struct ix86_address *);
>  extern int memory_address_length (rtx, bool);
>  extern void x86_output_aligned_bss (FILE *, tree, const char *,
> -                                   unsigned HOST_WIDE_INT, int);
> +                                   unsigned HOST_WIDE_INT, unsigned);
>  extern void x86_elf_aligned_decl_common (FILE *, tree, const char *,
> -                                        unsigned HOST_WIDE_INT, int);
> +                                        unsigned HOST_WIDE_INT, unsigned);
>
>  #ifdef RTX_CODE
>  extern void ix86_fp_comparison_codes (enum rtx_code code, enum rtx_code *,
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 876a19f4c1f..f86d11dfb11 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -837,7 +837,7 @@ x86_64_elf_unique_section (tree decl, int reloc)
>  void
>  x86_elf_aligned_decl_common (FILE *file, tree decl,
>                         const char *name, unsigned HOST_WIDE_INT size,
> -                       int align)
> +                       unsigned align)
>  {
>    if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
>        && size > (unsigned int)ix86_section_threshold)
> @@ -858,7 +858,7 @@ x86_elf_aligned_decl_common (FILE *file, tree decl,
>
>  void
>  x86_output_aligned_bss (FILE *file, tree decl, const char *name,
> -                       unsigned HOST_WIDE_INT size, int align)
> +                       unsigned HOST_WIDE_INT size, unsigned align)
>  {
>    if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
>        && size > (unsigned int)ix86_section_threshold)
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix x86/56337 : 1<<28 alignment is broken
  2021-08-30 21:21 ` Andrew Pinski
@ 2021-08-31  6:11   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2021-08-31  6:11 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Andrew Pinski, GCC Patches

On Mon, Aug 30, 2021 at 11:38 PM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Fri, Jul 23, 2021 at 1:33 PM apinski--- via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > From: Andrew Pinski <apinski@marvell.com>
> >
> > The problem here is the x86_64 back-end uses a signed integer
> > for alignment and then divides by BITS_PER_UNIT so if we had
> > INT_MIN (which is what 1<<28*8 is), we would get the wrong result.
> >
> > This fixes the problem by using unsigned for the argument to
> > x86_output_aligned_bss and x86_output_aligned_bss.
> >
> > OK? Bootstrapped and tested on x86_64-linux-gnu.
>
> Ping?

OK.

Thanks,
Richard.

> >
> > gcc/ChangeLog:
> >
> >         PR target/56337
> >         * config/i386/i386-protos.h (x86_output_aligned_bss):
> >         Change align argument to unsigned type.
> >         (x86_elf_aligned_decl_common): Likewise.
> >         * config/i386/i386.c (x86_elf_aligned_decl_common): Likewise.
> >         (x86_output_aligned_bss): Likewise.
> > ---
> >  gcc/config/i386/i386-protos.h | 4 ++--
> >  gcc/config/i386/i386.c        | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
> > index 07ac02aff69..fa1b0d0d787 100644
> > --- a/gcc/config/i386/i386-protos.h
> > +++ b/gcc/config/i386/i386-protos.h
> > @@ -325,9 +325,9 @@ struct ix86_address
> >  extern int ix86_decompose_address (rtx, struct ix86_address *);
> >  extern int memory_address_length (rtx, bool);
> >  extern void x86_output_aligned_bss (FILE *, tree, const char *,
> > -                                   unsigned HOST_WIDE_INT, int);
> > +                                   unsigned HOST_WIDE_INT, unsigned);
> >  extern void x86_elf_aligned_decl_common (FILE *, tree, const char *,
> > -                                        unsigned HOST_WIDE_INT, int);
> > +                                        unsigned HOST_WIDE_INT, unsigned);
> >
> >  #ifdef RTX_CODE
> >  extern void ix86_fp_comparison_codes (enum rtx_code code, enum rtx_code *,
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index 876a19f4c1f..f86d11dfb11 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -837,7 +837,7 @@ x86_64_elf_unique_section (tree decl, int reloc)
> >  void
> >  x86_elf_aligned_decl_common (FILE *file, tree decl,
> >                         const char *name, unsigned HOST_WIDE_INT size,
> > -                       int align)
> > +                       unsigned align)
> >  {
> >    if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
> >        && size > (unsigned int)ix86_section_threshold)
> > @@ -858,7 +858,7 @@ x86_elf_aligned_decl_common (FILE *file, tree decl,
> >
> >  void
> >  x86_output_aligned_bss (FILE *file, tree decl, const char *name,
> > -                       unsigned HOST_WIDE_INT size, int align)
> > +                       unsigned HOST_WIDE_INT size, unsigned align)
> >  {
> >    if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
> >        && size > (unsigned int)ix86_section_threshold)
> > --
> > 2.17.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-31  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 20:32 [PATCH] Fix x86/56337 : 1<<28 alignment is broken apinski
2021-08-30 21:21 ` Andrew Pinski
2021-08-31  6:11   ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).