http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45871

           Summary: lto bootstrap miscompiles expmed.c1
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: andi-...@firstfloor.org


On x86_64-linux:

Doing a lto bootstrap (BUILD_CONFIG=bootstrap-lto) with current trunk
(last change 2010-10-03  Uros Bizjak  <ubiz...@gmail.com>) 
ends with ICEs (for each file tried) on the compilation of 
the 32bit libgcc2 in stage2.

It looks like expmed.c is miscompiled for the stage1 compiler and 
jumps to a hardcoded NULL:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000009b788b in store_bit_field_1 (str_rtx=<value optimized out>,
bitsize=15, bitnum=112, fieldmode=VOIDmode, 
    value=<value optimized out>, fallback_p=1 '\001') at
../../gcc/gcc/expmed.c:657
#2  0x00000000009b809f in store_bit_field (str_rtx=<value optimized out>,
bitsize=<value optimized out>, 
    bitnum=<value optimized out>, fieldmode=<value optimized out>, value=<value
optimized out>) at ../../gcc/gcc/expmed.c:833
#3  0x0000000000772ffe in store_field (target=0x7ffff6a37378, bitsize=15,
bitpos=112, mode=VOIDmode, 
    exp=<value optimized out>, type=<value optimized out>, alias_set=0,
nontemporal=0 '\000') at ../../gcc/gcc/expr.c:5969
#4  store_field (target=0x7ffff6a37378, bitsize=15, bitpos=112, mode=VOIDmode,
exp=<value optimized out>, 
    type=<value optimized out>, alias_set=0, nontemporal=0 '\000') at
../../gcc/gcc/expr.c:5820
#5  0x0000000000773b5a in expand_assignment (to=0x7ffff6d78600,
from=0x7ffff68eee18, nontemporal=0 '\000')
    at ../../gcc/gcc/expr.c:4352
#6  expand_assignment (to=0x7ffff6d78600, from=0x7ffff68eee18, nontemporal=0
'\000') at ../../gcc/gcc/expr.c:4150
#7  0x00000000008ce344 in expand_gimple_stmt_1 (stmt=0x7ffff6bcb4b0) at
../../gcc/gcc/cfgexpand.c:1892
#8  expand_gimple_stmt (stmt=0x7ffff6bcb4b0) at ../../gcc/gcc/cfgexpand.c:2001
#9  0x00000000008ceda6 in expand_gimple_basic_block (bb=0x7ffff6be2b60) at
../../gcc/gcc/cfgexpand.c:3453
#10 0x00000000008d2842 in gimple_expand_cfg () at
../../gcc/gcc/cfgexpand.c:3913
#11 0x0000000000b528bf in execute_one_pass (pass=0xf3ab40) at
../../gcc/gcc/passes.c:1569
#12 0x0000000000b52c95 in execute_pass_list (pass=0xf3ab40) at
../../gcc/gcc/passes.c:1624
#13 0x0000000000c0c624 in tree_rest_of_compilation (fndecl=0x7ffff6cd6c00) at
../../gcc/gcc/tree-optimize.c:419
#14 0x0000000000aeca86 in cgraph_expand_function (node=0x7ffff6d11160) at
../../gcc/gcc/cgraphunit.c:1477
#15 0x0000000000aedfa2 in cgraph_expand_all_functions () at
../../gcc/gcc/cgraphunit.c:1556
#16 cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1812
#17 cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1743
#18 0x0000000000aee83a in cgraph_finalize_compilation_unit () at
../../gcc/gcc/cgraphunit.c:1020
#19 0x0000000000793803 in c_write_global_declarations () at
../../gcc/gcc/c-decl.c:9747
#20 c_write_global_declarations () at ../../gcc/gcc/c-decl.c:9701
#21 0x0000000000b8807c in compile_file (argc=83, argv=0x7fffffffdb98) at
../../gcc/gcc/toplev.c:951
#22 do_compile (argc=83, argv=0x7fffffffdb98) at ../../gcc/gcc/toplev.c:2379
#23 toplev_main (argc=83, argv=0x7fffffffdb98) at ../../gcc/gcc/toplev.c:2420
(gdb) up
#1  0x00000000009b788b in store_bit_field_1 (str_rtx=<value optimized out>,
bitsize=15, bitnum=112, fieldmode=VOIDmode, 
    value=<value optimized out>, fallback_p=1 '\001') at
../../gcc/gcc/expmed.c:657
657           && insn_data[CODE_FOR_insv].operand[1].predicate (GEN_INT
(bitsize),
(gdb) l
652           && GET_MODE (value) != BLKmode
653           && bitsize > 0
654           && GET_MODE_BITSIZE (op_mode) >= bitsize
655           && ! ((REG_P (op0) || GET_CODE (op0) == SUBREG)
656                 && (bitsize + bitpos > GET_MODE_BITSIZE (op_mode)))
657           && insn_data[CODE_FOR_insv].operand[1].predicate (GEN_INT
(bitsize),
658                                                             VOIDmode)
659           && check_predicate_volatile_ok (CODE_FOR_insv, 0, op0, VOIDmode))
660         {
661           int xbitpos = bitpos;


Stepping through it: 

It enters the predicate gen_rtx_CONST_INT and returns and then runs 
into a hardcoded NULL jump in store_bit_field_1:

(gdb) 
0x00000000009df018 in gen_rtx_CONST_INT (mode=<value optimized out>, arg=15) at
../../gcc/gcc/emit-rtl.c:422
422     }
2: x/3i $pc
=> 0x9df018 <gen_rtx_CONST_INT+56>:     retq   
   0x9df019 <gen_rtx_CONST_INT+57>:     nopl   0x0(%rax)
   0x9df020 <gen_rtx_CONST_INT+64>:     mov    0x65c431(%rip),%rdi        #
0x103b458 <const_int_htab.997056>
(gdb) 
0x00000000009b7882 in store_bit_field_1 (str_rtx=<value optimized out>,
bitsize=15, bitnum=112, fieldmode=VOIDmode, 
    value=<value optimized out>, fallback_p=1 '\001') at
../../gcc/gcc/expmed.c:657
657           && insn_data[CODE_FOR_insv].operand[1].predicate (GEN_INT
(bitsize),
2: x/3i $pc
=> 0x9b7882 <store_bit_field_1+1570>:   xor    %esi,%esi
   0x9b7884 <store_bit_field_1+1572>:   mov    %rax,%rdi
   0x9b7887 <store_bit_field_1+1575>:   xor    %eax,%eax
(gdb) 
0x00000000009b7884      657           &&
insn_data[CODE_FOR_insv].operand[1].predicate (GEN_INT (bitsize),
2: x/3i $pc
=> 0x9b7884 <store_bit_field_1+1572>:   mov    %rax,%rdi
   0x9b7887 <store_bit_field_1+1575>:   xor    %eax,%eax
   0x9b7889 <store_bit_field_1+1577>:   callq  *%rax
(gdb) 
0x00000000009b7887      657           &&
insn_data[CODE_FOR_insv].operand[1].predicate (GEN_INT (bitsize),
2: x/3i $pc
=> 0x9b7887 <store_bit_field_1+1575>:   xor    %eax,%eax
   0x9b7889 <store_bit_field_1+1577>:   callq  *%rax
   0x9b788b <store_bit_field_1+1579>:   test   %eax,%eax

That obviously jumps to NULL.

Reply via email to