aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/inline.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-08-19 08:35:31 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-19 08:35:31 +0000
commita4bbe10deb69d4885baffde7fa42c0ba137e7dc8 (patch)
tree9676dddec5b7540cc78fa28fecea9e361005fde2 /gcc/ada/inline.adb
parent04d933fd48d7e7cbedb761d660229cac9f36fab2 (diff)
downloadgcc-a4bbe10deb69d4885baffde7fa42c0ba137e7dc8.zip
gcc-a4bbe10deb69d4885baffde7fa42c0ba137e7dc8.tar.gz
gcc-a4bbe10deb69d4885baffde7fa42c0ba137e7dc8.tar.bz2
[Ada] Further cleanup in inlining machinery
This gets rid of a small issue in the inlining machinery: under very peculiar circumstances, it would add a pending instantiation for the body of a generic package at the point of call to an inlined subprogram of the instance. That's theoritically problematic because the saved context is that of the call and not that of the instance in this case, although the strict conditions ensure that this doesn't make a real difference in practice. Now that the machinery can perform the pending instantiations on demand, we can optimistically add more of them when the instantiations are analyzed and thus remove the problematic handling at the point of call. No functional changes. 2019-08-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * inline.adb (Add_Inlined_Body): Do not add pending instantiations. * sem_ch12.adb (Needs_Body_Instantiated): New predicate. (Analyze_Package_Instantiation): Use it to decide whether to add a pending instantiation for the body of the package. From-SVN: r274639
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r--gcc/ada/inline.adb37
1 files changed, 6 insertions, 31 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index 84ad1ab..f7bb1a9 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -510,7 +510,6 @@ package body Inline is
Inst : Entity_Id;
Inst_Decl : Node_Id;
- Inst_Node : Node_Id;
Level : Inline_Level_Type;
-- Start of processing for Add_Inlined_Body
@@ -609,48 +608,24 @@ package body Inline is
and then Is_Generic_Instance (Inst)
and then not Is_Called (Inst)
then
- -- Do not add a pending instantiation if the body exits
- -- already, or if the instance is a compilation unit, or
- -- the instance node is missing.
-
Inst_Decl := Unit_Declaration_Node (Inst);
+
+ -- Do not inline the instance if the body already exists,
+ -- or if the instance is a compilation unit, or else if
+ -- the instance node is simply missing.
+
if Present (Corresponding_Body (Inst_Decl))
or else Nkind (Parent (Inst_Decl)) = N_Compilation_Unit
or else No (Next (Inst_Decl))
then
Set_Is_Called (Inst);
-
else
- -- If the inlined call itself appears within an instance,
- -- ensure that the enclosing instance body is available.
- -- This is necessary because Sem_Ch12.Might_Inline_Subp
- -- does not recurse into nested instantiations.
-
- if not Is_Inlined (Inst) and then In_Instance then
- Set_Is_Inlined (Inst);
-
- -- The instantiation node usually follows the package
- -- declaration for the instance. If the generic unit
- -- has aspect specifications, they are transformed
- -- into pragmas in the instance, and the instance node
- -- appears after them.
-
- Inst_Node := Next (Inst_Decl);
-
- while Nkind (Inst_Node) /= N_Package_Instantiation loop
- Inst_Node := Next (Inst_Node);
- end loop;
-
- Add_Pending_Instantiation (Inst_Node, Inst_Decl);
- end if;
-
Add_Inlined_Instance (Inst);
end if;
end if;
end if;
- -- If the unit containing E is an instance, then the instance body
- -- will be analyzed in any case, see Sem_Ch12.Might_Inline_Subp.
+ -- If the unit containing E is an instance, nothing more to do
if Is_Generic_Instance (Pack) then
null;