public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7900] ada: Fix memory explosion on aggregate of nested packed array type Date: Wed, 27 Sep 2023 08:28:01 +0000 (GMT) [thread overview] Message-ID: <20230927082801.08FB83865C2A@sourceware.org> (raw) https://gcc.gnu.org/g:0c28157ba7edb36329447008553be7d050e09a02 commit r13-7900-g0c28157ba7edb36329447008553be7d050e09a02 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Tue Jul 11 13:29:55 2023 +0200 ada: Fix memory explosion on aggregate of nested packed array type It occurs at compile time on an aggregate of a 2-dimensional packed array type whose component type is itself a packed array, because the compiler is trying to pack the intermediate aggregate and ends up rewriting a bunch of subcomponents. This optimization was originally devised for the case of a scalar component type so the change adds this restriction. gcc/ada/ * exp_aggr.adb (Is_Two_Dim_Packed_Array): Return true only if the component type of the array is scalar. Diff: --- gcc/ada/exp_aggr.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index b0bd8c0b29a..f78d339961e 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -328,7 +328,7 @@ package body Exp_Aggr is -- N is the N_Aggregate node to be expanded. function Is_Two_Dim_Packed_Array (Typ : Entity_Id) return Boolean; - -- For two-dimensional packed aggregates with constant bounds and constant + -- For 2D packed array aggregates with constant bounds and constant scalar -- components, it is preferable to pack the inner aggregates because the -- whole matrix can then be presented to the back-end as a one-dimensional -- list of literals. This is much more efficient than expanding into single @@ -9217,9 +9217,11 @@ package body Exp_Aggr is function Is_Two_Dim_Packed_Array (Typ : Entity_Id) return Boolean is C : constant Uint := Component_Size (Typ); + begin return Number_Dimensions (Typ) = 2 and then Is_Bit_Packed_Array (Typ) + and then Is_Scalar_Type (Component_Type (Typ)) and then C in Uint_1 | Uint_2 | Uint_4; -- False if No_Uint end Is_Two_Dim_Packed_Array;
reply other threads:[~2023-09-27 8:28 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230927082801.08FB83865C2A@sourceware.org \ --to=ebotcazou@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).