OSDN Git Service

PR optimization/11646
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Sep 2003 07:11:01 +0000 (07:11 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 17 Sep 2003 07:11:01 +0000 (07:11 +0000)
* cfgrtl.c (purge_dead_edges) [JUMP_INSN]: Rematerialize the
EDGE_ABNORMAL flag for EH edges.
* toplev.c (rest_of_handle_cse): Delete unreachable blocks
if dead edges were purged.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71455 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgrtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/cfg3.C [new file with mode: 0644]
gcc/toplev.c

index 9062d99..aa323e2 100644 (file)
@@ -1,3 +1,11 @@
+2003-09-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR optimization/11646
+       * cfgrtl.c (purge_dead_edges) [JUMP_INSN]: Rematerialize the
+       EDGE_ABNORMAL flag for EH edges.
+       * toplev.c (rest_of_handle_cse): Delete unreachable blocks
+       if dead edges were purged.
+
 2003-09-16  Bernardo Innocenti  <bernie@develer.com>
 
        * config/m68k/m68k.h (TARGET_CPU_CPP_BUILTINS): Add target predefines.
index 7441cd9..f383438 100644 (file)
@@ -2255,8 +2255,12 @@ purge_dead_edges (basic_block bb)
            continue;
          else if ((e->flags & EDGE_EH) && can_throw_internal (insn))
            /* Keep the edges that correspond to exceptions thrown by
-              this instruction.  */
-           continue;
+              this instruction and rematerialize the EDGE_ABNORMAL
+              flag we just cleared above.  */
+           {
+             e->flags |= EDGE_ABNORMAL;
+             continue;
+           }
 
          /* We do not need this edge.  */
          bb->flags |= BB_DIRTY;
index e7cf798..fae6be7 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-17  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * g++.dg/opt/cfg3.C: New test.
+
 2003-09-16  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/7939
diff --git a/gcc/testsuite/g++.dg/opt/cfg3.C b/gcc/testsuite/g++.dg/opt/cfg3.C
new file mode 100644 (file)
index 0000000..123c2f5
--- /dev/null
@@ -0,0 +1,61 @@
+// PR optimization/11646
+// Origin: <nick@ilm.com>
+
+// This used to fail because the compiler inadvertently cleared
+// the EDGE_ABNORMAL flag on a EDGE_EH edge and didn't delete
+// unreachable blocks after CSE.
+
+// { dg-do compile }
+// { dg-options "-O -fgcse -fnon-call-exceptions" }
+
+struct C
+{
+  int i;
+};
+
+struct allocator
+{
+  ~allocator() throw() {}
+};
+
+struct _Vector_alloc_base
+{
+  _Vector_alloc_base(const allocator& __a) {}
+  allocator _M_data_allocator;
+  struct C *_M_start, *_M_end_of_storage;
+  void _M_deallocate(struct C* __p, unsigned int __n) {}
+};
+
+struct _Vector_base : _Vector_alloc_base
+{
+  _Vector_base(const allocator& __a) : _Vector_alloc_base(__a) { }
+  ~_Vector_base() { _M_deallocate(0, _M_end_of_storage - _M_start); }
+};
+
+struct vector : _Vector_base
+{
+  vector(const allocator& __a = allocator()) : _Vector_base(__a) {}
+  struct C& operator[](unsigned int __n) { return *_M_start; }
+};
+
+struct A
+{
+  float l() const;
+  A operator-(const A &) const;
+  const A& operator=(float) const;
+};
+
+struct B
+{
+  float d();
+};
+
+float f(const A& a, B& b)
+{
+  vector vc;
+  int index = vc[0].i;
+  A aa;
+  float d = (aa - a).l();
+  if (d > b.d()) aa = 0;
+    return b.d();
+}
index bcc9c50..91409bf 100644 (file)
@@ -2846,7 +2846,8 @@ rest_of_handle_cse (tree decl, rtx insns)
   tem = cse_main (insns, max_reg_num (), 0, rtl_dump_file);
   if (tem)
     rebuild_jump_labels (insns);
-  purge_all_dead_edges (0);
+  if (purge_all_dead_edges (0))
+    delete_unreachable_blocks ();
 
   delete_trivially_dead_insns (insns, max_reg_num ());