This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix overactive devirtualization to external functions
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 10 Sep 2013 15:53:57 +0200
- Subject: Fix overactive devirtualization to external functions
- Authentication-results: sourceware.org; auth=none
Hi,
fold_ctor_reference expects VAR or FUNCTION_DECL as FROM_DECL parameter.
gimple_get_virt_method_for_binfo instead passes expression
(pointer_plus_expr (addr_expr vtable_decl) (integer_cst XXX))
This bug makes can_refere_from_current_unit_p to mistakely think that
the references are safe because they come from code.
Fixed thus,
Bootstrapped/regtested x86_64-linux.
Honza
* gimple-fold.c (gimple_get_virt_method_for_binfo): Pass real
VAR_DECL of vtable rather than full expression.
Index: gimple-fold.c
===================================================================
--- gimple-fold.c (revision 202445)
+++ gimple-fold.c (working copy)
@@ -3135,7 +3135,7 @@ gimple_get_virt_method_for_binfo (HOST_W
size = tree_low_cst (TYPE_SIZE (TREE_TYPE (TREE_TYPE (v))), 1);
offset += token * size;
fn = fold_ctor_reference (TREE_TYPE (TREE_TYPE (v)), init,
- offset, size, vtable);
+ offset, size, v);
if (!fn || integer_zerop (fn))
return NULL_TREE;
gcc_assert (TREE_CODE (fn) == ADDR_EXPR