I get an internal compiler error with gcc-4.2.1 and my own back-end
when I support conditional execution:
../build/gcc/cc1 -Wall -O1 -o bug.O1.s bug.c
bug.c: In function ‘cond_assign_les0’:
bug.c:13: internal compiler error: in elim_reg_cond, at flow.c:3486
The test C file "bug.c" is:
int cond_assign_les0(int cond, int a, int b)
{
int res;
if(cond <= 0) {
res = a;
}
else {
res = b;
}
return(res);
}
int main(int argc, char **argv)
{
int res = cond_assign_les0(1, 0, 1);
return(res);
}
My "research" so far:
* This error appeared in older gcc versions and is marked as fixed.
* Support for conditional execution works for EQ and NE, but not for
the other kinds of condition, eg LE
* The ARM back-end works on the test code above without problems, and
I implemented support for conditional execution in my back-end the
same way.
* The RTX code x in elim_reg_cond is "UnKnown" (0), regno=48 is the
first virtual (not hardware) register (see trace below)
The backtrace is:
#0 elim_reg_cond (x=0x140b4ad90, regno=48) at ../../gcc-4.2.1/gcc/flow.c:3486
#1 0x00000001001bc58f in flush_reg_cond_reg_1 (node=0x1406092c0, data=<value
temporarily unavailable, due to optimizations>) at
../../gcc-4.2.1/gcc/flow.c:3192
#2 0x000000010034fa19 in splay_tree_foreach_helper (sp=0x140608e50,
node=0x1406092c0, fn=0x1001bc530 <flush_reg_cond_reg_1>, data=0x7fff5fbfe4b0)
at ../../gcc-4.2.1/libiberty/splay-tree.c:218
#3 0x00000001001bd484 in flush_reg_cond_reg [inlined] () at
/some/path/to/somewhere/gcc-4.2.1/gcc/flow.c:3217
#4 0x00000001001bd484 in mark_regno_cond_dead [inlined] () at
/some/path/to/somewhere/gcc-4.2.1/gcc/flow.c:3095
#5 0x00000001001bd484 in mark_set_1 (pbi=0x140608df0, code=<value temporarily
unavailable, due to optimizations>, reg=0x140bfc760, cond=0x0,
insn=0x140b2d5f0, flags=16) at ../../gcc-4.2.1/gcc/flow.c:2895
#6 0x00000001001bf8a4 in propagate_one_insn (pbi=0x140608df0,
insn=0x140b2d5f0) at ../../gcc-4.2.1/gcc/flow.c:1864
#7 0x00000001001c009d in propagate_block (bb=0x140bfd680, live=<value
temporarily unavailable, due to optimizations>, local_set=<value temporarily
unavailable, due to optimizations>, cond_local_set=<value temporarily
unavailable, due to optimizations>, flags=1085462000) at
../../gcc-4.2.1/gcc/flow.c:2218
#8 0x00000001001c0ad3 in update_life_info (blocks=0x140601990,
extent=UPDATE_LIFE_GLOBAL_RM_NOTES, prop_flags=25) at
../../gcc-4.2.1/gcc/flow.c:1345
#9 0x00000001001c14b6 in update_life_info_in_dirty_blocks
(extent=UPDATE_LIFE_GLOBAL_RM_NOTES, prop_flags=25) at
../../gcc-4.2.1/gcc/flow.c:763
#10 0x00000001002095eb in if_convert (x_life_data_ok=<value temporarily
unavailable, due to optimizations>) at ../../gcc-4.2.1/gcc/ifcvt.c:3922
#11 0x0000000100209722 in rest_of_handle_if_after_reload () at
../../gcc-4.2.1/gcc/ifcvt.c:4041
#12 0x00000001002da597 in execute_one_pass (pass=0x10042a080) at
../../gcc-4.2.1/gcc/passes.c:881
#13 0x00000001002da6f8 in execute_pass_list (pass=0x10042a080) at
../../gcc-4.2.1/gcc/passes.c:932
#14 0x00000001002da70a in execute_pass_list (pass=0x10042b600) at
../../gcc-4.2.1/gcc/passes.c:933
#15 0x00000001002da70a in execute_pass_list (pass=0x10042b5a0) at
../../gcc-4.2.1/gcc/passes.c:933
#16 0x000000010007d5b2 in tree_rest_of_compilation (fndecl=0x140bec1c0) at
../../gcc-4.2.1/gcc/tree-optimize.c:463
#17 0x000000010000a945 in c_expand_body (fndecl=0x140bec1c0) at
../../gcc-4.2.1/gcc/c-decl.c:6836
#18 0x0000000100313663 in cgraph_expand_function (node=0x140bfa000) at
../../gcc-4.2.1/gcc/cgraphunit.c:1244
#19 0x0000000100314c3e in cgraph_expand_all_functions [inlined] () at
/some/path/to/somewhere/gcc-4.2.1/gcc/cgraphunit.c:1309
#20 0x0000000100314c3e in cgraph_optimize () at
../../gcc-4.2.1/gcc/cgraphunit.c:1588
#21 0x000000010000d5c2 in c_write_global_declarations () at
../../gcc-4.2.1/gcc/c-decl.c:7951
#22 0x00000001002b8058 in toplev_main (argc=<value temporarily unavailable, due
to optimizations>, argv=<value temporarily unavailable, due to optimizations>)
at ../../gcc-4.2.1/gcc/toplev.c:1046
#23 0x0000000100001604 in start ()
So, I think it's not a GCC problem, but I do something wrong in my
back-end. What could I have done wrong? Register description?
Thanks in advance,
Boris