diff mbox

[Ada] Inhibit exception push/pop when not needed

Message ID 20111104140923.GA8407@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Nov. 4, 2011, 2:09 p.m. UTC
This patch inhibits the generation of exception push/pop nodes if
restriction No_Exception_Handlers is active (when they are always
useless), or in CodePeer mode (where they are never needed and can
intefere with the analysis).

The following program

     1. pragma Restrictions (No_Exception_Propagation);
     2. pragma Restrictions (No_Exception_Handlers);
     3. function NoPush (X : Integer) return Integer is
     4. begin
     5.    return 10 / X;
     6. end;

should generate the following -gnatG output:

Source recreated from tree for Nopush (body)

pragma restrictions (no_exception_propagation);
pragma restrictions (no_exception_handlers);

function nopush (x : integer) return integer is
begin
   [constraint_error when
     x = 0
     "divide by zero"]
   return integer(10 / x);
end nopush;

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

2011-11-04  Robert Dewar  <dewar@adacore.com>

	* exp_ch11.adb (Generate_Push_Pop): Inhibit push/pop nodes in
	CodePeer mode or if restriction No_Exception_Handlers is present.
	* exp_ch6.adb (Expand_N_Subprogram_Body): (Inhibit push/pop
	nodes in CodePeer mode or if restriction No_Exception_Handlers
	is present.

Comments

Iain Sandoe Nov. 4, 2011, 3:06 p.m. UTC | #1
On 4 Nov 2011, at 14:09, Arnaud Charlet wrote:

> This patch inhibits the generation of exception push/pop nodes if
> restriction No_Exception_Handlers is active (when they are always
> useless), or in CodePeer mode (where they are never needed and can
> intefere with the analysis).

this latest series breaks bootstrap on at least i686-darwin9.

at 180951 (I'll need to wind backwards to find which particular patch  
- unless it's obvious to you).

-- is a follow-up planned?

Iain

exp_alfa.adb:37:06: "Sem_Util (spec)" depends on "Nmake (body)"
exp_alfa.adb:37:06: "Nmake (body)" depends on "Nmake (spec)"
exp_alfa.adb:37:06: file "nmake.ads" not found
exp_alfa.adb:37:06: "Exp_Alfa (body)" depends on "Sem_Util (spec)"
exp_alfa.adb:37:06: "Sem_Util (spec)" depends on "Nmake (spec)"
make[3]: *** [ada/exp_alfa.o] Error 1
Arnaud Charlet Nov. 4, 2011, 3:29 p.m. UTC | #2
>> This patch inhibits the generation of exception push/pop nodes if
>> restriction No_Exception_Handlers is active (when they are always
>> useless), or in CodePeer mode (where they are never needed and can
>> intefere with the analysis).
> 
> this latest series breaks bootstrap on at least i686-darwin9.
> 
> at 180951 (I'll need to wind backwards to find which particular patch -
> unless it's obvious to you).
> 
> -- is a follow-up planned?

It's an issue related to parallel builds (a missing dependency).

I'll double check that and will fix shortly.

Arno
diff mbox

Patch

Index: exp_ch11.adb
===================================================================
--- exp_ch11.adb	(revision 180934)
+++ exp_ch11.adb	(working copy)
@@ -334,7 +334,7 @@ 
       --  raise statements into gotos, e.g. all N_Raise_xxx_Error nodes are
       --  left unchanged and passed to the back end.
 
-      --  Instead, the front end generates two nodes
+      --  Instead, the front end generates three nodes
 
       --     N_Push_Constraint_Error_Label
       --     N_Push_Program_Error_Label
@@ -356,6 +356,10 @@ 
       --  field in the Push node will be empty signifying that for this region
       --  of code, no optimization is possible.
 
+      --  These Push/Pop nodes are inhibited if No_Exception_Handlers is set
+      --  since they are useless in this case, and in CodePeer mode, where
+      --  they serve no purpose and can intefere with the analysis.
+
       --  The back end must maintain three stacks, one for each exception case,
       --  the Push node pushes an entry onto the corresponding stack, and Pop
       --  node pops off the entry. Then instead of calling Rcheck_nn, if the
@@ -503,6 +507,12 @@ 
 
          procedure Generate_Push_Pop (H : Node_Id) is
          begin
+            if Restriction_Active (No_Exception_Handlers)
+              or else CodePeer_Mode
+            then
+               return;
+            end if;
+
             if Exc_Locally_Handled then
                return;
             else
Index: exp_ch6.adb
===================================================================
--- exp_ch6.adb	(revision 180934)
+++ exp_ch6.adb	(working copy)
@@ -5679,10 +5679,14 @@ 
       end if;
 
       --  If local-exception-to-goto optimization active, insert dummy push
-      --  statements at start, and dummy pop statements at end.
+      --  statements at start, and dummy pop statements at end, but inhibit
+      --  this if we have No_Exception_Handlers, since they are useless and
+      --  intefere with analysis, e.g. by codepeer.
 
       if (Debug_Flag_Dot_G
            or else Restriction_Active (No_Exception_Propagation))
+        and then not Restriction_Active (No_Exception_Handlers)
+        and then not CodePeer_Mode
         and then Is_Non_Empty_List (L)
       then
          declare