[Ada] Build activation chain for BIP only when needed

Message ID 20211109094536.GA829884@adacore.com
State Committed
Commit 74e514af79c4e01a6ff7fab4b7c7a79cad058c3c
Headers
Series [Ada] Build activation chain for BIP only when needed |

Commit Message

Pierre-Marie de Rodat Nov. 9, 2021, 9:45 a.m. UTC
  In some cases, BIP references tasking while it is not needed.  Check if
this is needed before adding this reference.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch6.adb (Expand_Actuals): Add a condition to check for the
	possibility of task.
  

Patch

diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -2292,8 +2292,11 @@  package body Exp_Ch6 is
                null;
 
             elsif Is_Build_In_Place_Function_Call (Actual) then
-               Build_Activation_Chain_Entity (N);
-               Build_Master_Entity (Etype (Actual));
+               if Might_Have_Tasks (Etype (Actual)) then
+                  Build_Activation_Chain_Entity (N);
+                  Build_Master_Entity (Etype (Actual));
+               end if;
+
                Make_Build_In_Place_Call_In_Anonymous_Context (Actual);
 
             --  Ada 2005 (AI-318-02): Specialization of the previous case for