From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1314) id CE5C73858405; Tue, 31 Aug 2021 06:29:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE5C73858405 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Pinski To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3242] Fix x86/56337 : 1<<28 alignment is broken X-Act-Checkin: gcc X-Git-Author: Andrew Pinski X-Git-Refname: refs/heads/trunk X-Git-Oldrev: d904008df267cbcc01bd6edf98fa0789fb6e94da X-Git-Newrev: e4d86078881bb7bb57bc6e68c22211707d2b3dc7 Message-Id: <20210831062916.CE5C73858405@sourceware.org> Date: Tue, 31 Aug 2021 06:29:16 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2021 06:29:16 -0000 https://gcc.gnu.org/g:e4d86078881bb7bb57bc6e68c22211707d2b3dc7 commit r12-3242-ge4d86078881bb7bb57bc6e68c22211707d2b3dc7 Author: Andrew Pinski Date: Fri Jul 23 17:21:06 2021 +0000 Fix x86/56337 : 1<<28 alignment is broken 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. Diff: --- 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 2fd13074c81..355df116439 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -326,9 +326,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 3bb2cab57a3..4681b667fa2 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -841,7 +841,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) @@ -862,7 +862,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)