aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-10-09 15:05:29 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-10-09 15:05:29 +0000
commit73efc7ff4c07b08d8c8ab5e5deeb00d5586878e3 (patch)
tree3d49d245b0a425b412cf9bcec11d0e8041a3e26c
parente7e72f9b7a03cc9756ee5bff4c1b39a226228222 (diff)
downloadgcc-73efc7ff4c07b08d8c8ab5e5deeb00d5586878e3.zip
gcc-73efc7ff4c07b08d8c8ab5e5deeb00d5586878e3.tar.gz
gcc-73efc7ff4c07b08d8c8ab5e5deeb00d5586878e3.tar.bz2
[Ada] Unnesting: avoid unnecessary loads of System
2018-10-09 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * exp_unst.adb (Unnest_Subprogram): Do not load System to obtain the Address entity unless an activation record is being built. Removes useless with_clauses for System when nested subprograms do not have uplevel references, and therefore do not need activation records. From-SVN: r264967
-rw-r--r--gcc/ada/ChangeLog8
-rw-r--r--gcc/ada/exp_unst.adb25
2 files changed, 23 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e7ce7ee..aee5a62 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,13 @@
2018-10-09 Ed Schonberg <schonberg@adacore.com>
+ * exp_unst.adb (Unnest_Subprogram): Do not load System to obtain
+ the Address entity unless an activation record is being built.
+ Removes useless with_clauses for System when nested subprograms
+ do not have uplevel references, and therefore do not need
+ activation records.
+
+2018-10-09 Ed Schonberg <schonberg@adacore.com>
+
* sem_ch6.adb (Fully_Conformant_Expressions): Handle properly
the conformance check on an aspect expression that includes a
call to an instance of Unchecked_Conversion, or more generally a
diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb
index de4ea1a..0b63aa6 100644
--- a/gcc/ada/exp_unst.adb
+++ b/gcc/ada/exp_unst.adb
@@ -746,6 +746,10 @@ package body Exp_Unst is
procedure Register_Subprogram (E : Entity_Id; Bod : Node_Id) is
L : constant Nat := Get_Level (Subp, E);
+ -- Subprograms declared in tasks and protected types cannot
+ -- be eliminated because calls to them may be in other units,
+ -- so they must be treated as reachable.
+
begin
-- Subprograms declared in tasks and protected types cannot
-- be eliminated because calls to them may be in other units,
@@ -756,10 +760,6 @@ package body Exp_Unst is
Bod => Bod,
Lev => L,
Reachable => In_Synchronized_Unit (E),
-
- -- Subprograms declared in tasks and protected types are
- -- reachable and cannot be eliminated.
-
Uplevel_Ref => L,
Declares_AREC => False,
Uents => No_Elist,
@@ -1148,7 +1148,7 @@ package body Exp_Unst is
return Skip;
end if;
- -- Pragmas and component declarations can be ignored
+ -- Pragmas and component declarations can be ignored.
-- Quantified expressions are expanded into explicit loops
-- and the original epression must be ignored.
@@ -1383,10 +1383,10 @@ package body Exp_Unst is
-- If this entity was marked reachable because it is
-- in a task or protected type, there may not appear
- -- to be any calls to it, which would normally adjust
- -- the levels of the parent subprograms. So we need to
- -- be sure that the uplevel reference of that entity
- -- takes into account possible calls.
+ -- to be any calls to it, which would normally
+ -- adjust the levels of the parent subprograms.
+ -- So we need to be sure that the uplevel reference
+ -- of that entity takes into account possible calls.
if In_Synchronized_Unit (SUBF.Ent)
and then SUBT.Lev < SUBI.Uplevel_Ref
@@ -1627,7 +1627,7 @@ package body Exp_Unst is
-- Loop through subprograms
Subp_Loop : declare
- Addr : constant Entity_Id := RTE (RE_Address);
+ Addr : Entity_Id := Empty;
begin
for J in Subps_First .. Subps.Last loop
@@ -1745,9 +1745,14 @@ package body Exp_Unst is
begin
-- Build list of component declarations for ARECnT
+ -- and load System.Address.
Clist := Empty_List;
+ if No (Addr) then
+ Addr := RTE (RE_Address);
+ end if;
+
-- If we are in a subprogram that has a static link that
-- is passed in (as indicated by ARECnF being defined),
-- then include ARECnU : ARECmPT where ARECmPT comes from