public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-520] [Ada] Enable current value propagation within pragma expressions
@ 2022-05-17  8:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-17  8:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bc17882341b506a7e1052fa5be7ddbb3220cb2b1

commit r13-520-gbc17882341b506a7e1052fa5be7ddbb3220cb2b1
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Mar 16 21:50:08 2022 +0100

    [Ada] Enable current value propagation within pragma expressions
    
    This patch fixes an odd incomplete optimization within pragma
    expressions. For example, in this code:
    
       X := True;
       pragma Assert (X = True);
       pragma Assert (X);
    
    the first assertion was eliminated by the frontend (regardless of the
    optimization switches), while the second assertion was only eliminated
    by the backend and only with switch -O1 or similar.
    
    The problem was that the current value propagation was disabled for
    references immediately within pragma argument associations. This was
    meant to avoid a crash when such a reference appears in pragma
    Inspection_Point, but this wasn't a proper fix. The proper solution is
    rather to not expand references in pragma Inspection_Point at all.
    
    Actually, this expansion was enabled to avoid a yet another crash, when
    the parameter of pragma Inspection_Point is a prival (i.e. a renaming of
    private protected component). It turns out that none of these suspicious
    problematic fixes is no longer necessary.
    
    Cleanup related to fixes of current value propagation in expansion of
    attribute Loop_Entry.
    
    gcc/ada/
    
            * exp_ch2.adb (Expand_Current_Value): Remove special case for
            references immediately within pragma argument associations.
            * exp_prag.adb (Expand_Pragma_Inspection_Point): Remove special
            case for privals.

Diff:
---
 gcc/ada/exp_ch2.adb  | 7 -------
 gcc/ada/exp_prag.adb | 8 +-------
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb
index 921a8b76754..8f97b438203 100644
--- a/gcc/ada/exp_ch2.adb
+++ b/gcc/ada/exp_ch2.adb
@@ -150,13 +150,6 @@ package body Exp_Ch2 is
 
          and then OK_To_Do_Constant_Replacement (E)
 
-         --  Do not replace occurrences in pragmas (where names typically
-         --  appear not as values, but as simply names. If there are cases
-         --  where values are required, it is only a very minor efficiency
-         --  issue that they do not get replaced when they could be).
-
-         and then Nkind (Parent (N)) /= N_Pragma_Argument_Association
-
          --  Do not replace the prefixes of attribute references, since this
          --  causes trouble with cases like 4'Size. Also for Name_Asm_Input and
          --  Name_Asm_Output, don't do replacement anywhere, since we can have
diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
index 27ea708f64d..86a3929466a 100644
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -34,7 +34,6 @@ with Elists;         use Elists;
 with Errout;         use Errout;
 with Exp_Ch11;       use Exp_Ch11;
 with Exp_Util;       use Exp_Util;
-with Expander;       use Expander;
 with Inline;         use Inline;
 with Lib;            use Lib;
 with Namet;          use Namet;
@@ -2390,10 +2389,7 @@ package body Exp_Prag is
          Set_Pragma_Argument_Associations (N, A);
       end if;
 
-      --  Process the arguments of the pragma and expand them. Expanding an
-      --  entity reference is a noop, except in a protected operation, where
-      --  a reference may have to be transformed into a reference to the
-      --  corresponding prival. Are there other pragmas that require this ???
+      --  Process the arguments of the pragma
 
       Rip := False;
       Assoc := First (Pragma_Argument_Associations (N));
@@ -2402,8 +2398,6 @@ package body Exp_Prag is
 
          Set_Address_Taken (Entity (Expression (Assoc)));
 
-         Expand (Expression (Assoc));
-
          --  If any of the objects have a freeze node, it must appear before
          --  pragma Inspection_Point, otherwise the entity won't be elaborated
          --  when Gigi processes the pragma.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-17  8:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17  8:27 [gcc r13-520] [Ada] Enable current value propagation within pragma expressions Pierre-Marie de Rodat

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).