aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-03-16 21:50:08 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-17 08:25:40 +0000
commitbc17882341b506a7e1052fa5be7ddbb3220cb2b1 (patch)
tree8569c4769e1a1c24bce85ede1b45d1d05f0a3b19
parentbc9aa450eb47e440a4b909a10a271fe074e896eb (diff)
downloadgcc-bc17882341b506a7e1052fa5be7ddbb3220cb2b1.zip
gcc-bc17882341b506a7e1052fa5be7ddbb3220cb2b1.tar.gz
gcc-bc17882341b506a7e1052fa5be7ddbb3220cb2b1.tar.bz2
[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.
-rw-r--r--gcc/ada/exp_ch2.adb7
-rw-r--r--gcc/ada/exp_prag.adb8
2 files changed, 1 insertions, 14 deletions
diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb
index 921a8b7..8f97b43 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 27ea708..86a3929 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.