[Bug tree-optimization/55823] [4.8 Regression] ice in inline_call, at ipa-inline-transform.c:270

hubicka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 3 16:23:00 GMT 2013


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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> 2013-01-03 16:22:43 UTC ---
Hi,
the problem is that at the time ipa_get_indirect_edge_target is called from
devirt_benefit on _ZN12wxBufferedDC10InitCommonEP8wxDCBase.constprop.1/33 being
inlined it is seeing following info:
(gdb) p debug_tree (binfo)
 <tree_binfo 0x7ffff6db6138
    type <record_type 0x7ffff6dca348 wxWindowDC sizes-gimplified addressable
tree_2 needs-constructing type_5 BLK
        size <integer_cst 0x7ffff6c50dc0 constant 64>
        unit size <integer_cst 0x7ffff6c50de0 constant 8>
        align 64 symtab 0 alias set 5 canonical type 0x7ffff6dca348
        fields <field_decl 0x7ffff6db5b48 D.2218 type <record_type
0x7ffff6db9690 wxDCBase>
            ignored decl_6 BLK file /home/jan/t.C line 8 col 8 size
<integer_cst 0x7ffff6c50dc0 64> unit size <integer_cst 0x7ffff6c50de0 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff6c50e00 constant 0>
            bit offset <integer_cst 0x7ffff6c50e80 constant 0> context
<record_type 0x7ffff6dca348 wxWindowDC> chain <type_decl 0x7ffff6db3cf0
wxWindowDC>> context <translation_unit_decl 0x7ffff6c69170 D.1>
        full-name "struct wxWindowDC"
        needs-constructor X() X(constX&) this=(X&) n_parents=1 use_template=0
interface-unknown
        pointer_to_this <pointer_type 0x7ffff6dd2d20> reference_to_this
<reference_type 0x7ffff6dd9540> chain <type_decl 0x7ffff6db3c38 wxWindowDC>>
    private tree_2>


(gdb) p debug_tree (otr_type)
 <record_type 0x7ffff6db9690 wxDCBase sizes-gimplified addressable tree_2
needs-constructing type_1 type_5 BLK
    size <integer_cst 0x7ffff6c50dc0 type <integer_type 0x7ffff6c6b0a8
bitsizetype> constant 64>
    unit size <integer_cst 0x7ffff6c50de0 type <integer_type 0x7ffff6c6b000
sizetype> constant 8>
    align 64 symtab 0 alias set 2 canonical type 0x7ffff6db9690
    fields <field_decl 0x7ffff6db5850 _vptr.wxDCBase
        type <pointer_type 0x7ffff6db01f8 type <pointer_type 0x7ffff6db00a8
__vtbl_ptr_type>
            sizes-gimplified public unsigned DI size <integer_cst
0x7ffff6c50dc0 64> unit size <integer_cst 0x7ffff6c50de0 8>
            align 64 symtab 0 alias set 3 canonical type 0x7ffff6db01f8>
        unsigned virtual DI file /home/jan/t.C line 2 col 8 size <integer_cst
0x7ffff6c50dc0 64> unit size <integer_cst 0x7ffff6c50de0 8>
        align 64 offset_align 128
        offset <integer_cst 0x7ffff6c50e00 constant 0>
        bit offset <integer_cst 0x7ffff6c50e80 constant 0> context <record_type
0x7ffff6db9690 wxDCBase>
        chain <type_decl 0x7ffff6db3ac8 wxDCBase type <record_type
0x7ffff6db9738 wxDCBase>
            used nonlocal decl_4 VOID file /home/jan/t.C line 3 col 1
            align 1 context <record_type 0x7ffff6db9690 wxDCBase> result
<record_type 0x7ffff6db9690 wxDCBase>
           >> context <translation_unit_decl 0x7ffff6c69170 D.1>
    full-name "struct wxDCBase"
    needs-constructor X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
    pointer_to_this <pointer_type 0x7ffff6db9930> reference_to_this
<reference_type 0x7ffff6dd2540> chain <type_decl 0x7ffff6db3a10 wxDCBase>>

(gdb) p anc_offset
$33 = 0

This leads to devirtualization.  It is because the info is known from function
itself. As noted earlier ipa-cp missed it for no valid reasons.

Now we inline and go to:
0x0000000000a9ce3b in update_indirect_edges_after_inlining (cs=0x7ffff6de62d8,
node=0x7ffff6dd3378, new_edges=0x7fffffffda20) at ../../gcc/ipa-prop.c:2284

0x0000000000a9ce3b in update_indirect_edges_after_inlining (cs=0x7ffff6de62d8,
node=0x7ffff6dd3378, new_edges=0x7fffffffda20) at ../../gcc/ipa-prop.c:2284
2284                  ici->offset += ipa_get_jf_ancestor_offset (jfunc);
(gdb) l
2279                  && !ipa_get_jf_ancestor_agg_preserved (jfunc))
2280                ici->param_index = -1;
2281              else
2282                {
2283                  ici->param_index = ipa_get_jf_ancestor_formal_id (jfunc);
2284                  ici->offset += ipa_get_jf_ancestor_offset (jfunc);
2285                }
2286            }

at this time the jump functions are updated for inlining into
_ZN17wxBufferedPaintDCC2Ev.constprop.0.
This time we cast to ancestor (if I get everything right) and the offset is
updated to 64.

Now try_make_edge_direct_virtual_call is called and it sees ANCESTOR jfunc and
at

2211      binfo = get_binfo_at_offset (binfo, ie->indirect_info->offset,
2212                                   ie->indirect_info->otr_type);

it passes the same binfo

 <tree_binfo 0x7ffff6db6138
    type <record_type 0x7ffff6dca348 wxWindowDC sizes-gimplified addressable
tree_2 needs-constructing type_5 BLK
        size <integer_cst 0x7ffff6c50dc0 constant 64>
        unit size <integer_cst 0x7ffff6c50de0 constant 8>
        align 64 symtab 0 alias set 5 canonical type 0x7ffff6dca348
        fields <field_decl 0x7ffff6db5b48 D.2218 type <record_type
0x7ffff6db9690 wxDCBase>
            ignored decl_6 BLK file /home/jan/t.C line 8 col 8 size
<integer_cst 0x7ffff6c50dc0 64> unit size <integer_cst 0x7ffff6c50de0 8>
            align 64 offset_align 128
            offset <integer_cst 0x7ffff6c50e00 constant 0>
            bit offset <integer_cst 0x7ffff6c50e80 constant 0> context
<record_type 0x7ffff6dca348 wxWindowDC> chain <type_decl 0x7ffff6db3cf0
wxWindowDC>> context <translation_unit_decl 0x7ffff6c69170 D.1>
        full-name "struct wxWindowDC"
        needs-constructor X() X(constX&) this=(X&) n_parents=1 use_template=0
interface-unknown
        pointer_to_this <pointer_type 0x7ffff6dd2d20> reference_to_this
<reference_type 0x7ffff6dd9540> chain <type_decl 0x7ffff6db3c38 wxWindowDC>>
    private tree_2>

but already combined offset 64.  This leads to nothing.

How this is supposed to work?
It is using jump functions of the call site we are seeing.

I am confused. I do not see how devirtualization/indirect call code can work
after we update jump functions to new context. In partiuclar what happens when
the parameter is constant?  It seems that the following code:

      if (jfunc->type == IPA_JF_PASS_THROUGH
          && ipa_get_jf_pass_through_operation (jfunc) == NOP_EXPR)
        {
          if (ici->agg_contents
              && !ipa_get_jf_pass_through_agg_preserved (jfunc))
            ici->param_index = -1;
          else
            ici->param_index = ipa_get_jf_pass_through_formal_id (jfunc);
        }
      else if (jfunc->type == IPA_JF_ANCESTOR)
        {
          if (ici->agg_contents
              && !ipa_get_jf_ancestor_agg_preserved (jfunc))
            ici->param_index = -1;
          else
            {
              ici->param_index = ipa_get_jf_ancestor_formal_id (jfunc);
              ici->offset += ipa_get_jf_ancestor_offset (jfunc);
            }
        }
      else
        /* Either we can find a destination for this edge now or never. */
        ici->param_index = -1;

will drop ici->param_index to -1 before we do any attempt to devirtualize so we
simply miss the information given.

Second it seems that the combining of offsets is wrong.  wxWindowDC is empty
wrapper
around wxDCBase. From where the offset is comming?

Honza



More information about the Gcc-bugs mailing list