Re: ICE on bootstrap of libstdc++ for mingw-targets in add_bb_to_loop

2012-04-10 Thread Richard Guenther
On Tue, Apr 10, 2012 at 12:41 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Hello,

 recent changes to cfgloop have caused an ICE on bootstrapping
 libstdc++ for mingw targets.  I assume same ICE happens for cygwin
 hosted gcc bootstrap, too. ICE happens on compiling of
 gcc/libstdc++-v3/libsupc++/eh_alloc.cc

 Code which produces seg-fault is in macro:

      DEF_VEC_P (loop_p);

 backtrace:

 #0  add_bb_to_loop (bb=0x7ef68ca0, loop=0x0) at ../../gcc/gcc/cfgloop.h:88

loop is NULL, so the issue is that mingw somewhere generates a basic-block
without a loop father.

 #1  0x00a5e3d7 in split_block (bb=0x7ef68bc8, i=0x7eb6ea30)

for this block (bb).

Find out where it is generated and fix that.

Richard.

    at ../../gcc/gcc/cfghooks.c:450
 #2  0x00abaf49 in find_many_sub_basic_blocks (blocks=0x442f178)
    at ../../gcc/gcc/cfgbuild.c:474
 #3  0x008a280f in break_superblocks () at ../../gcc/gcc/cfglayout.c:1345
 #4  0x007293f9 in finish_eh_generation () at ../../gcc/gcc/except.c:1431
 #5  0x00dc06f4 in gimple_expand_cfg () at ../../gcc/gcc/cfgexpand.c:4652
 #6  0x008d4afc in execute_one_pass (pass=0x1143bc0)
    at ../../gcc/gcc/passes.c:2079
 #7  0x008d4cc4 in execute_pass_list (pass=0x4350238)
    at ../../gcc/gcc/passes.c:2134
 #8  0x00a8b1c4 in tree_rest_of_compilation (fndecl=0x7eca1d00)
    at ../../gcc/gcc/tree-optimize.c:422
 #9  0x008da273 in cgraph_expand_function (node=0x7ecd7578)
    at ../../gcc/gcc/cgraphunit.c:1784
 #10 0x008dc2d9 in cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1851
 #11 0x008dcb2e in cgraph_finalize_compilation_unit ()
    at ../../gcc/gcc/cgraphunit.c:2628
 #12 0x00510c5b in cp_write_global_declarations ()
    at ../../gcc/gcc/cp/decl2.c:4077
 #13 0x008e6452 in toplev_main (argc=30, argv=0x43497d0)
    at ../../gcc/gcc/toplev.c:572
 #14 0x006a104a in main (argc=30, argv=0x43497d0) at ../../gcc/gcc/main.c:36


Re: ICE on bootstrap of libstdc++ for mingw-targets in add_bb_to_loop

2012-04-10 Thread Kai Tietz
Hi,

issue was that TARGET_EXCEPT_UNWIND_INFO wasn't set for i386
architectures.  As mingw targets are using SjLj, it is necessary that
this hook is present.

ChangeLog

2012-04-10  Kai Tietz  kti...@redhat.com

PR c++/52918
* common/config/i386/i386-common.c (ix86_except_unwind_info):
Add target-hook for supporting SjLj.

Tested for x86_64-w64-mingw32, and for x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai


Index: common/config/i386/i386-common.c
===
--- common/config/i386/i386-common.c(revision 186264)
+++ common/config/i386/i386-common.c(working copy)
@@ -667,6 +667,26 @@
   return ret;
 }

+/* Implement TARGET_EXCEPT_UNWIND_INFO.  */
+
+static enum unwind_info_type
+ix86_except_unwind_info (struct gcc_options *opts)
+{
+  /* Honor the --enable-sjlj-exceptions configure switch.  */
+#ifdef CONFIG_SJLJ_EXCEPTIONS
+  if (CONFIG_SJLJ_EXCEPTIONS)
+return UI_SJLJ;
+#endif
+
+  /* For simplicity elsewhere in this file, indicate that all unwind
+ info is disabled if we're not emitting unwind tables.  */
+  if (!opts-x_flag_exceptions  !opts-x_flag_unwind_tables)
+return UI_NONE;
+
+  return UI_TARGET;
+}
+
+
 #undef TARGET_DEFAULT_TARGET_FLAGS
 #define TARGET_DEFAULT_TARGET_FLAGS\
   (TARGET_DEFAULT  \
@@ -684,4 +704,7 @@
 #undef TARGET_SUPPORTS_SPLIT_STACK
 #define TARGET_SUPPORTS_SPLIT_STACK ix86_supports_split_stack

+#undef TARGET_EXCEPT_UNWIND_INFO
+#define TARGET_EXCEPT_UNWIND_INFO  ix86_except_unwind_info
+
 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;


Re: ICE on bootstrap of libstdc++ for mingw-targets in add_bb_to_loop

2012-04-10 Thread Kai Tietz
Sorry, for the noise.  This patch just activates dw2 and therefore
avoids the ICE.

Continue on that.

Kai


Re: ICE on bootstrap of libstdc++ for mingw-targets in add_bb_to_loop

2012-04-10 Thread Kai Tietz
Hi,

issue was caused by the patch for PR middle-end/52772, which just
handles dw2.  This patch makes sure that for sjlj we add new generated
bb's for dispatching table to loop, too.

ChangeLog

2012-04-10  Kai Tietz  kti...@redhat.com

PR c++/52924
* except.c (sjlj_emit_dispatch_table): Add bb to loop,
as done for dwarf2.

Bootstrapped for x64_64-w64-mingw32, and x86_64-unknown-linux-gnu.
Later for all languages including Ada and Obj-C++.

Ok for apply?

Regards,
Kai

Index: except.c
===
--- except.c(revision 186288)
+++ except.c(working copy)
@@ -1344,6 +1344,16 @@
e = make_edge (bb, bb-next_bb, EDGE_FALLTHRU);
e-count = bb-count;
e-probability = REG_BR_PROB_BASE;
+   if (current_loops)
+ {
+   struct loop *loop = bb-next_bb-loop_father;
+   /* If we created a pre-header block, add the new block to the
+  outer loop, otherwise to the loop itself.  */
+   if (bb-next_bb == loop-header)
+ add_bb_to_loop (bb, loop_outer (loop));
+   else
+ add_bb_to_loop (bb, loop);
+ }

disp_index++;
   }
@@ -1365,6 +1375,17 @@
   e-count = bb-count;
   e-probability = REG_BR_PROB_BASE;
 }
+
+  if (current_loops)
+{
+  struct loop *loop = bb-next_bb-loop_father;
+  /* If we created a pre-header block, add the new block to the
+outer loop, otherwise to the loop itself.  */
+  if (bb-next_bb == loop-header)
+   add_bb_to_loop (bb, loop_outer (loop));
+  else
+   add_bb_to_loop (bb, loop);
+}
 }

 static void