This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make ir_type differentiate between cfgrtl and cfglayout mode
- From: Serge Belyshev <belyshev at depni dot sinp dot msu dot ru>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 23 Nov 2006 19:42:53 +0300
- Subject: Re: [PATCH] Make ir_type differentiate between cfgrtl and cfglayout mode
- References: <200611010659.44677.steven@gcc.gnu.org>
Steven Bosscher <stevenb.gcc@gmail.com> writes:
> Hello,
>
> With this patch, we can tell more easily whether we're in cfglayout
> mode or in cfgrtl mode. This becomes necessary when some functions
> that previously would see every insn when walking the insns list.
> In cfglayout mode the non-insns between basic blocks are not in that
> list. This causes e.g. rebuild_jump_labels to miss all the labels
> in jump tables, so I need a way to tell such functions to look in
> the bb header and footer as well. This seems the cleanest solution
> to me.
>
Hi!
This patch creates few new failures in testsuite if compiler was
configured with gcac checking. All of them are
"internal compiler error: in current_ir_type, at cfghooks.c:70":
FAIL: gcc.dg/pch/except-1.c -O0 -g (internal compiler error)
FAIL: gcc.dg/pch/inline-1.c -O0 -g (internal compiler error)
FAIL: gcc.dg/pch/inline-2.c -O0 -g (internal compiler error)
FAIL: gcc.dg/pch/inline-3.c -O0 -g (internal compiler error)
FAIL: gcc.dg/pch/inline-4.c -O0 -g (internal compiler error)
FAIL: gcc.dg/pch/system-1.c -O0 -g (internal compiler error)
The actual cause is simple: we are calling current_ir_type()
from garbage collector before any of *_register_cfg_hooks() functions
was ever called, here is backtrace:
#0 fancy_abort (file=0x15366d0 "/home/ssb/src/r/gcc43/gcc/cfghooks.c", line=70, function=0x15366c0 "current_ir_type") at /home/ssb/src/r/gcc43/gcc/diagnostic.c:642
#1 0x000000000104736f in current_ir_type () at /home/ssb/src/r/gcc43/gcc/cfghooks.c:70
#2 0x00000000008ae956 in gt_ggc_mx_edge_def (x_p=0x100000a100) at gtype-desc.c:375
#3 0x00000000008ae590 in gt_ggc_mx_VEC_edge_gc (x_p=0x100019b710) at gtype-desc.c:237
#4 0x00000000008af7fe in gt_ggc_mx_basic_block_def (x_p=0x100018a100) at gtype-desc.c:696
#5 0x00000000008af53b in gt_ggc_mx_tree_ann_d (x_p=0x100013f850) at gtype-desc.c:618
#6 0x000000000042b793 in gt_ggc_mx_lang_tree_node (x_p=0x1000220410) at ./gt-c-decl.h:381
#7 0x00000000008aef20 in gt_ggc_mx_tree_statement_list_node (x_p=0x10002150a0) at gtype-desc.c:519
#8 0x000000000042bc66 in gt_ggc_mx_lang_tree_node (x_p=0x1000194510) at ./gt-c-decl.h:451
#9 0x000000000042b30c in gt_ggc_mx_lang_tree_node (x_p=0x100020f0c0) at ./gt-c-decl.h:323
#10 0x00000000008ae21a in gt_ggc_mx_cgraph_node (x_p=0x1000142240) at gtype-desc.c:166
#11 0x00000000008b2bfb in gt_ggc_m_P11cgraph_node4htab (x_p=0x100013f460) at gtype-desc.c:1759
#12 0x00000000008ac7f1 in ggc_mark_roots () at /home/ssb/src/r/gcc43/gcc/ggc-common.c:118
#13 0x0000000001054c18 in ggc_collect () at /home/ssb/src/r/gcc43/gcc/ggc-page.c:1906
#14 0x000000000049cbd5 in c_parser_translation_unit (parser=0x2add0b5d6410) at /home/ssb/src/r/gcc43/gcc/c-parser.c:1094
#15 0x00000000004aa923 in c_parse_file () at /home/ssb/src/r/gcc43/gcc/c-parser.c:7858
#16 0x000000000048e1ba in c_common_parse_file (set_yydebug=0) at /home/ssb/src/r/gcc43/gcc/c-opts.c:1182
#17 0x0000000000fee588 in compile_file () at /home/ssb/src/r/gcc43/gcc/toplev.c:1033
#18 0x0000000000feff71 in do_compile () at /home/ssb/src/r/gcc43/gcc/toplev.c:2010
#19 0x0000000000feffd5 in toplev_main (argc=6, argv=0x7fff9f96f588) at /home/ssb/src/r/gcc43/gcc/toplev.c:2042
#20 0x00000000004bbb2f in main (argc=6, argv=0x7fff9f96f588) at /home/ssb/src/r/gcc43/gcc/main.c:35
cfg_hooks is NULL here, so we are calling gcc_unreachable ():
(gdb) f 1
#1 0x000000000104736f in current_ir_type () at /home/ssb/src/r/gcc43/gcc/cfghooks.c:70
70 gcc_unreachable ();
(gdb) p cfg_hooks
$1 = (struct cfg_hooks *) 0x0
And both 't' and 'r' in union edge_def_insns are NULL too:
(gdb) f 2
#2 0x00000000008ae956 in gt_ggc_mx_edge_def (x_p=0x100000a100) at gtype-desc.c:375
375 switch (current_ir_type () == IR_GIMPLE)
(gdb) p (*x).insns.t
$2 = (tree) 0x0
(gdb) p (*x).insns.r
$3 = (rtx) 0x0
>
> Index: cfghooks.c
> ===================================================================
> --- cfghooks.c (revision 118333)
> +++ cfghooks.c (working copy)
> @@ -55,12 +55,19 @@ tree_register_cfg_hooks (void)
> cfg_hooks = &tree_cfg_hooks;
> }
>
> -/* Returns current ir type (rtl = 0, trees = 1). */
> +/* Returns current ir type. */
>
> -int
> -ir_type (void)
> +enum ir_type
> +current_ir_type (void)
> {
> - return cfg_hooks == &tree_cfg_hooks ? 1 : 0;
> + if (cfg_hooks == &tree_cfg_hooks)
> + return IR_GIMPLE;
> + else if (cfg_hooks == &rtl_cfg_hooks)
> + return IR_RTL_CFGRTL;
> + else if (cfg_hooks == &cfg_layout_rtl_cfg_hooks)
> + return IR_RTL_CFGLAYOUT;
> + else
> + gcc_unreachable ();
> }
>
> /* Verify the CFG consistency.
> Index: basic-block.h
> ===================================================================
> --- basic-block.h (revision 118333)
> +++ basic-block.h (working copy)
> @@ -123,9 +123,9 @@ struct edge_def GTY(())
>
> /* Instructions queued on the edge. */
> union edge_def_insns {
> - rtx GTY ((tag ("0"))) r;
> - tree GTY ((tag ("1"))) t;
> - } GTY ((desc ("ir_type ()"))) insns;
> + tree GTY ((tag ("true"))) t;
> + rtx GTY ((tag ("false"))) r;
> + } GTY ((desc ("current_ir_type () == IR_GIMPLE"))) insns;
>
> /* Auxiliary info specific to a pass. */
> PTR GTY ((skip (""))) aux;