From 3e27aa84ef34539400456774ade5f2caaa20b5e9 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 16 Jul 2006 14:31:05 +0000 Subject: [PATCH] optabs.c (maybe_encapsulate_block): New function extracted from... * 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 | 7 +++ gcc/optabs.c | 62 +++++++++++---------- gcc/testsuite/ChangeLog | 6 ++ gcc/testsuite/gnat.dg/assert.ads | 5 ++ gcc/testsuite/gnat.dg/controlled_record.adb | 15 +++++ gcc/testsuite/gnat.dg/controlled_record.ads | 16 ++++++ 6 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/assert.ads create mode 100644 gcc/testsuite/gnat.dg/controlled_record.adb create mode 100644 gcc/testsuite/gnat.dg/controlled_record.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a16b05640f7..28c4534b708 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-07-16 Eric Botcazou + + * 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 * doc/install.texi (sparc-sun-solaris2*): Add GMP version number. diff --git a/gcc/optabs.c b/gcc/optabs.c index 5b50f9dceed..a961bd49b53 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -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); } /* Nonzero if we can perform a comparison of mode MODE straightforwardly. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 92606e25ba2..9e7e540c9fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-07-16 Olivier Hainque + + * gnat.dg/assert.ads: New file. + * gnat.dg/controlled_record.ads: Likewise. + * gnat.dg/controlled_record.adb: Likewise. + 2006-07-15 Lee Millward PR c++/28292 diff --git a/gcc/testsuite/gnat.dg/assert.ads b/gcc/testsuite/gnat.dg/assert.ads new file mode 100644 index 00000000000..81a912a8ad2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/assert.ads @@ -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 index 00000000000..89a9380b9d2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/controlled_record.adb @@ -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 index 00000000000..71a57372c96 --- /dev/null +++ b/gcc/testsuite/gnat.dg/controlled_record.ads @@ -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; -- 2.30.2