public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2125] [Ada] Optimize away certain elaboration checks Date: Wed, 7 Jul 2021 16:26:31 +0000 (GMT) [thread overview] Message-ID: <20210707162631.6835F396DC2A@sourceware.org> (raw) https://gcc.gnu.org/g:29d3965161a8c9337a8b46019eea184ff3a6ac61 commit r12-2125-g29d3965161a8c9337a8b46019eea184ff3a6ac61 Author: Bob Duff <duff@adacore.com> Date: Wed May 19 14:24:13 2021 -0400 [Ada] Optimize away certain elaboration checks gcc/ada/ * checks.adb (Install_Primitive_Elaboration_Check): Do not generate elaboration checks for primitives if pragma Pure or Preelaborate is present. Misc comment fixes, including referring to the correct kind of check (elaboration, not accessibility). * checks.ads, restrict.adb, sem_cat.ads, sinfo.ads: Minor reformatting and comment fixes. Diff: --- gcc/ada/checks.adb | 23 +++++++++++++++-------- gcc/ada/checks.ads | 2 +- gcc/ada/restrict.adb | 5 ++--- gcc/ada/sem_cat.ads | 2 +- gcc/ada/sinfo.ads | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 61ce9c22c04..cebeac5ab0c 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -48,6 +48,7 @@ with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Ch3; use Sem_Ch3; with Sem_Ch8; use Sem_Ch8; +with Sem_Cat; use Sem_Cat; with Sem_Disp; use Sem_Disp; with Sem_Eval; use Sem_Eval; with Sem_Mech; use Sem_Mech; @@ -84,7 +85,7 @@ package body Checks is -- such as Apply_Scalar_Range_Check that do not insert any code can be -- safely called even when the Expander is inactive (but Errors_Detected -- is 0). The benefit of executing this code when expansion is off, is - -- the ability to emit constraint error warning for static expressions + -- the ability to emit constraint error warnings for static expressions -- even when we are not generating code. -- The above is modified in gnatprove mode to ensure that proper check @@ -8634,7 +8635,7 @@ package body Checks is return; -- Do not generate an elaboration check if the related subprogram is - -- not subjected to accessibility checks. + -- not subject to elaboration checks. elsif Elaboration_Checks_Suppressed (Subp_Id) then return; @@ -8644,14 +8645,20 @@ package body Checks is elsif Restriction_Active (No_Elaboration_Code) then return; + -- If pragma Pure or Preelaborate applies, then these elaboration checks + -- cannot fail, so do not generate them. + + elsif In_Preelaborated_Unit then + return; + -- Do not generate an elaboration check if exceptions cannot be used, -- caught, or propagated. elsif not Exceptions_OK then return; - -- Do not consider subprograms which act as compilation units, because - -- they cannot be the target of a dispatching call. + -- Do not consider subprograms that are compilation units, because they + -- cannot be the target of a dispatching call. elsif Nkind (Context) = N_Compilation_Unit then return; @@ -8681,10 +8688,10 @@ package body Checks is elsif Analyzed (Subp_Body) then return; - -- Do not consider primitives which occur within an instance that acts - -- as a compilation unit. Such an instance defines its spec and body out - -- of order (body is first) within the tree, which causes the reference - -- to the elaboration flag to appear as an undefined symbol. + -- Do not consider primitives that occur within an instance that is a + -- compilation unit. Such an instance defines its spec and body out of + -- order (body is first) within the tree, which causes the reference to + -- the elaboration flag to appear as an undefined symbol. elsif Within_Compilation_Unit_Instance (Subp_Id) then return; diff --git a/gcc/ada/checks.ads b/gcc/ada/checks.ads index 130f871dcdd..a3835d9a4fd 100644 --- a/gcc/ada/checks.ads +++ b/gcc/ada/checks.ads @@ -357,7 +357,7 @@ package Checks is -- if so inserts the appropriate run-time check. procedure Install_Primitive_Elaboration_Check (Subp_Body : Node_Id); - -- Insert a check which ensures that subprogram body Subp_Body has been + -- Insert a check to ensure that subprogram body Subp_Body has been -- properly elaborated. The check is installed only when Subp_Body is the -- body of a nonabstract library-level primitive of a tagged type. Further -- restrictions may apply, see the body for details. diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb index 4f1dea4adef..d97a42eb2f5 100644 --- a/gcc/ada/restrict.adb +++ b/gcc/ada/restrict.adb @@ -396,10 +396,9 @@ package body Restrict is N : Node_Id; V : Uint := Uint_Minus_1) is - Msg_Issued : Boolean; - pragma Unreferenced (Msg_Issued); + Ignore_Msg_Issued : Boolean; begin - Check_Restriction (Msg_Issued, R, N, V); + Check_Restriction (Ignore_Msg_Issued, R, N, V); end Check_Restriction; procedure Check_Restriction diff --git a/gcc/ada/sem_cat.ads b/gcc/ada/sem_cat.ads index 3fa3339d09b..90a713bd871 100644 --- a/gcc/ada/sem_cat.ads +++ b/gcc/ada/sem_cat.ads @@ -27,7 +27,7 @@ -- the semantic restrictions required for the categorization pragmas: -- -- Preelaborate --- Pure, +-- Pure -- Remote_Call_Interface -- Remote_Types -- Shared_Passive diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 25a61ad5665..71da7fc583e 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -2082,7 +2082,7 @@ package Sinfo is -- that no elaboration check is needed on the call, because it appears in -- the context of a local Suppress pragma. This is used on calls within -- task bodies, where the actual elaboration checks are applied after - -- analysis, when the local scope stack is not present + -- analysis, when the local scope stack is not present. -- No_Entities_Ref_In_Spec -- Present in N_With_Clause nodes. Set if the with clause is on the
reply other threads:[~2021-07-07 16:26 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=20210707162631.6835F396DC2A@sourceware.org \ --to=pmderodat@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).