From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 3C0173858C51; Tue, 17 May 2022 08:27:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C0173858C51 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-520] [Ada] Enable current value propagation within pragma expressions X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: bc9aa450eb47e440a4b909a10a271fe074e896eb X-Git-Newrev: bc17882341b506a7e1052fa5be7ddbb3220cb2b1 Message-Id: <20220517082722.3C0173858C51@sourceware.org> Date: Tue, 17 May 2022 08:27:22 +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, 17 May 2022 08:27:22 -0000 https://gcc.gnu.org/g:bc17882341b506a7e1052fa5be7ddbb3220cb2b1 commit r13-520-gbc17882341b506a7e1052fa5be7ddbb3220cb2b1 Author: Piotr Trojanek 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.