optabs.c (maybe_encapsulate_block): New function extracted from...
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 16 Jul 2006 14:31:05 +0000 (14:31 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 16 Jul 2006 14:31:05 +0000 (14:31 +0000)
* optabs.c (maybe_encapsulate_block): New function extracted from...
(emit_libcall_block): ...here.  Invoke it on the block of insns to
maybe emit REG_LIBCALL/REG_RETVAL notes around the block.
(emit_no_conflict_block): Likewise.

From-SVN: r115498

gcc/ChangeLog
gcc/optabs.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/assert.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/controlled_record.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/controlled_record.ads [new file with mode: 0644]

index a16b05640f79c37571cd97e06039f27e394d7115..28c4534b708018ab3491481b1600c61f321f1746 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-16  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * optabs.c (maybe_encapsulate_block): New function extracted from...
+       (emit_libcall_block): ...here.  Invoke it on the block of insns to
+       maybe emit REG_LIBCALL/REG_RETVAL notes around the block.
+       (emit_no_conflict_block): Likewise.
+
 2006-07-16  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * doc/install.texi (sparc-sun-solaris2*): Add GMP version number.
index 5b50f9dceeda338ee7ddea1d9fd69816b4527d99..a961bd49b53a68150d79842eac67d60d0e1dc8d2 100644 (file)
@@ -3218,6 +3218,38 @@ no_conflict_move_test (rtx dest, rtx set, void *p0)
     p->must_stay = true;
 }
 
+/* Encapsulate the block starting at FIRST and ending with LAST, which is
+   logically equivalent to EQUIV, so it gets manipulated as a unit if it
+   is possible to do so.  */
+
+static void
+maybe_encapsulate_block (rtx first, rtx last, rtx equiv)
+{
+  if (!flag_non_call_exceptions || !may_trap_p (equiv))
+    {
+      /* We can't attach the REG_LIBCALL and REG_RETVAL notes when the
+        encapsulated region would not be in one basic block, i.e. when
+        there is a control_flow_insn_p insn between FIRST and LAST.  */
+      bool attach_libcall_retval_notes = true;
+      rtx insn, next = NEXT_INSN (last);
+
+      for (insn = first; insn != next; insn = NEXT_INSN (insn))
+       if (control_flow_insn_p (insn))
+         {
+           attach_libcall_retval_notes = false;
+           break;
+         }
+
+      if (attach_libcall_retval_notes)
+       {
+         REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
+                                                REG_NOTES (first));
+         REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
+                                               REG_NOTES (last));
+       }
+    }
+}
+
 /* Emit code to perform a series of operations on a multi-word quantity, one
    word at a time.
 
@@ -3339,10 +3371,7 @@ emit_no_conflict_block (rtx insns, rtx target, rtx op0, rtx op1, rtx equiv)
   else
     first = NEXT_INSN (prev);
 
-  /* Encapsulate the block so it gets manipulated as a unit.  */
-  REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
-                                        REG_NOTES (first));
-  REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first, REG_NOTES (last));
+  maybe_encapsulate_block (first, last, equiv);
 
   return last;
 }
@@ -3496,30 +3525,7 @@ emit_libcall_block (rtx insns, rtx target, rtx result, rtx equiv)
   else
     first = NEXT_INSN (prev);
 
-  /* Encapsulate the block so it gets manipulated as a unit.  */
-  if (!flag_non_call_exceptions || !may_trap_p (equiv))
-    {
-      /* We can't attach the REG_LIBCALL and REG_RETVAL notes
-        when the encapsulated region would not be in one basic block,
-        i.e. when there is a control_flow_insn_p insn between FIRST and LAST.
-       */
-      bool attach_libcall_retval_notes = true;
-      next = NEXT_INSN (last);
-      for (insn = first; insn != next; insn = NEXT_INSN (insn))
-       if (control_flow_insn_p (insn))
-         {
-           attach_libcall_retval_notes = false;
-           break;
-         }
-
-      if (attach_libcall_retval_notes)
-       {
-         REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
-                                                REG_NOTES (first));
-         REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
-                                               REG_NOTES (last));
-       }
-    }
+  maybe_encapsulate_block (first, last, equiv);
 }
 \f
 /* Nonzero if we can perform a comparison of mode MODE straightforwardly.
index 92606e25ba2cffa0c05841461c74f0c87b7355ff..9e7e540c9fabe21660ea59fa89784d6cab10295e 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-16  Olivier Hainque  <hainque@adacore.com>
+
+       * gnat.dg/assert.ads: New file.
+       * gnat.dg/controlled_record.ads: Likewise.
+       * gnat.dg/controlled_record.adb: Likewise.
+
 2006-07-15  Lee Millward  <lee.millward@gmail.com>
 
        PR c++/28292
diff --git a/gcc/testsuite/gnat.dg/assert.ads b/gcc/testsuite/gnat.dg/assert.ads
new file mode 100644 (file)
index 0000000..81a912a
--- /dev/null
@@ -0,0 +1,5 @@
+package Assert is
+
+   procedure Assert (Condition : Boolean);
+
+end Assert;
diff --git a/gcc/testsuite/gnat.dg/controlled_record.adb b/gcc/testsuite/gnat.dg/controlled_record.adb
new file mode 100644 (file)
index 0000000..89a9380
--- /dev/null
@@ -0,0 +1,15 @@
+-- { dg-do compile }
+-- { dg-options "-O2" }
+
+with Ada.Text_IO; use Ada.Text_IO;
+with Assert;
+
+package body Controlled_Record is
+   
+   procedure Assert_Invariants (PA : Point_T) is
+     PB : Point_T;
+   begin
+      Assert.Assert (PB.Pos = PA.Pos);
+   end;
+
+end Controlled_Record;
diff --git a/gcc/testsuite/gnat.dg/controlled_record.ads b/gcc/testsuite/gnat.dg/controlled_record.ads
new file mode 100644 (file)
index 0000000..71a5737
--- /dev/null
@@ -0,0 +1,16 @@
+with Ada.Finalization;
+
+package Controlled_Record is
+
+   type Point_T is limited private;
+   procedure Assert_Invariants (PA : Point_T);
+
+private
+
+   type Coords_T is array (1 .. 2) of Natural;
+
+   type Point_T is new Ada.Finalization.Controlled with record
+      Pos : Coords_T := (0, 0);
+   end record;
+
+end Controlled_Record;