On 2014.01.31 at 07:22 +0100, Jan Hubicka wrote:
> +tree
> +vtable_pointer_value_to_binfo (tree t)
> +{
> +  /* We expect &MEM[(void *)&virtual_table + 16B].
> +     We obtain object's BINFO from the context of the virtual table. 
> +     This one contains pointer to virtual table represented via
> +     POINTER_PLUS_EXPR.  Verify that this pointer match to what
> +     we propagated through.
> +
> +     In the case of virtual inheritance, the virtual tables may
> +     be nested, i.e. the offset may be different from 16 and we may
> +     need to dive into the type representation.  */
> +  if (t && TREE_CODE (t) == ADDR_EXPR
> +      && TREE_CODE (TREE_OPERAND (t, 0)) == MEM_REF
> +      && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t, 0), 0)) == ADDR_EXPR
> +      && TREE_CODE (TREE_OPERAND (TREE_OPERAND (t, 0), 1)) == INTEGER_CST
> +      && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 0), 0), 0))
> +       == VAR_DECL)
> +      && DECL_VIRTUAL_P (TREE_OPERAND (TREE_OPERAND
> +                                      (TREE_OPERAND (t, 0), 0), 0)))
> +    {
> +      tree vtable = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 0), 0), 0);
> +      tree offset = TREE_OPERAND (TREE_OPERAND (t, 0), 1);
> +      tree binfo = TYPE_BINFO (DECL_CONTEXT (vtable));
> +
> +      binfo = subbinfo_with_vtable_at_offset (binfo, offset, vtable);
> +      gcc_assert (binfo);
> +      return binfo;
> +    }
> +  return NULL;
> +}

I've tested your patch a little bit and hit the gcc_assert above:

markus@x4 tmp % cat test.ii
class A {
public:
  unsigned length;
};
class B {};
class MultiTermDocs : public virtual B {
protected:
  A readerTermDocs;
  A subReaders;
  virtual B *m_fn1(int *);
  virtual ~MultiTermDocs();
};
class C : MultiTermDocs {
  B *m_fn1(int *);
};
MultiTermDocs::~MultiTermDocs() {
  if (&readerTermDocs) {
    B *a;
    for (unsigned i = 0; i < subReaders.length; i++)
      (a != 0);
  }
}

B *C::m_fn1(int *) { return 0; }

markus@x4 tmp % g++ -O2 test.ii
test.ii: In destructor ‘virtual C::~C()’:
test.ii:24:32: internal compiler error: in vtable_pointer_value_to_binfo, at 
ipa-devirt.c:1082
 B *C::m_fn1(int *) { return 0; }
                                ^
0x9ca774 vtable_pointer_value_to_binfo(tree_node*)
        ../../gcc/gcc/ipa-devirt.c:1082
0x9e22b9 extr_type_from_vtbl_ptr_store
        ../../gcc/gcc/ipa-prop.c:606
0x9e22b9 check_stmt_for_type_change
        ../../gcc/gcc/ipa-prop.c:648
0xc18343 walk_aliased_vdefs_1
        ../../gcc/gcc/tree-ssa-alias.c:2472
0xc1846d walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*, tree_node*, 
void*), void*, bitmap_head**)
        ../../gcc/gcc/tree-ssa-alias.c:2491
0x9e1cba detect_type_change
        ../../gcc/gcc/ipa-prop.c:702
0x9e8b63 compute_complex_assign_jump_func
        ../../gcc/gcc/ipa-prop.c:1089
0x9e8b63 ipa_compute_jump_functions_for_edge
        ../../gcc/gcc/ipa-prop.c:1635
0x9eb882 ipa_compute_jump_functions
        ../../gcc/gcc/ipa-prop.c:1675
0x9eb882 ipa_analyze_node(cgraph_node*)
        ../../gcc/gcc/ipa-prop.c:2212
0x103ea7f ipcp_generate_summary
        ../../gcc/gcc/ipa-cp.c:3709
0xaa4906 execute_ipa_summary_passes(ipa_opt_pass_d*)
        ../../gcc/gcc/passes.c:2027
0x833dbb ipa_passes
        ../../gcc/gcc/cgraphunit.c:2070
0x833dbb compile()
        ../../gcc/gcc/cgraphunit.c:2174
0x834304 finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2329
0x62efce cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4447
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.


-- 
Markus

Reply via email to