From: Jan Hubicka Date: Mon, 26 Aug 2013 15:40:40 +0000 (+0200) Subject: * gimple-fold.c (gimple_get_virt_method_for_binfo): Use ctor_for_folding. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2aa3da06e03332d488613e98b4f1f523117ecce5;p=gcc.git * gimple-fold.c (gimple_get_virt_method_for_binfo): Use ctor_for_folding. From-SVN: r202002 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 19ddd93e036..29a8d558588 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2013-08-26 Jan Hubicka + + * gimple-fold.c (gimple_get_virt_method_for_binfo): Use ctor_for_folding. + 2013-08-26 Jan Hubicka * ipa.c (comdat_can_be_unshared_p_1): C++ constructors and destructors diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index df6aef534eb..e6baabfa03d 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -3097,7 +3097,7 @@ tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo) { unsigned HOST_WIDE_INT offset, size; - tree v, fn, vtable; + tree v, fn, vtable, init; vtable = v = BINFO_VTABLE (known_binfo); /* If there is no virtual methods table, leave the OBJ_TYPE_REF alone. */ @@ -3117,14 +3117,24 @@ gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo) v = TREE_OPERAND (v, 0); if (TREE_CODE (v) != VAR_DECL - || !DECL_VIRTUAL_P (v) - || !DECL_INITIAL (v) - || DECL_INITIAL (v) == error_mark_node) + || !DECL_VIRTUAL_P (v)) return NULL_TREE; + init = ctor_for_folding (v); + + /* The virtual tables should always be born with constructors. + and we always should assume that they are avaialble for + folding. At the moment we do not stream them in all cases, + but it should never happen that ctor seem unreachable. */ + gcc_assert (init); + if (init == error_mark_node) + { + gcc_assert (in_lto_p); + return NULL_TREE; + } gcc_checking_assert (TREE_CODE (TREE_TYPE (v)) == ARRAY_TYPE); size = tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (v))), 1); offset += token * size; - fn = fold_ctor_reference (TREE_TYPE (TREE_TYPE (v)), DECL_INITIAL (v), + fn = fold_ctor_reference (TREE_TYPE (TREE_TYPE (v)), init, offset, size, vtable); if (!fn || integer_zerop (fn)) return NULL_TREE;