diff options
author | Martin Jambor <mjambor@suse.cz> | 2010-10-11 20:45:23 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2010-10-11 20:45:23 +0200 |
commit | 3f1f0ae316e60e7d9c40e1fef5f24d92cd985a9a (patch) | |
tree | 8d6ed9719873c3ea29c68bb9687c7adf8babe3d8 /gcc/gimple-fold.c | |
parent | 90a2689f4d6b68b7542b0f7b04d66fea1cee5c0f (diff) | |
download | gcc-3f1f0ae316e60e7d9c40e1fef5f24d92cd985a9a.zip gcc-3f1f0ae316e60e7d9c40e1fef5f24d92cd985a9a.tar.gz gcc-3f1f0ae316e60e7d9c40e1fef5f24d92cd985a9a.tar.bz2 |
re PR middle-end/45699 (Incorrect copy constructor generated with -O)
2010-10-11 Martin Jambor <mjambor@suse.cz>
PR middle-end/45699
* gimple-fold.c (gimple_fold_obj_type_ref_known_binfo): Choose among
thunks.
* testsuite/g++.dg/torture/pr45699.C: New test.
* testsuite/g++.dg/otr-fold-1.C: Adjusted.
* testsuite/g++.dg/otr-fold-1.C: Likewise.
From-SVN: r165327
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index d412eb2..ce232e60 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1463,7 +1463,7 @@ tree gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo) { HOST_WIDE_INT i; - tree v, fndecl; + tree v, fndecl, delta; v = BINFO_VIRTUALS (known_binfo); i = 0; @@ -1475,6 +1475,25 @@ gimple_fold_obj_type_ref_known_binfo (HOST_WIDE_INT token, tree known_binfo) } fndecl = TREE_VALUE (v); + delta = TREE_PURPOSE (v); + gcc_assert (host_integerp (delta, 0)); + + if (integer_nonzerop (delta)) + { + struct cgraph_node *node = cgraph_get_node (fndecl); + HOST_WIDE_INT off = tree_low_cst (delta, 0); + + if (!node) + return NULL; + for (node = node->same_body; node; node = node->next) + if (node->thunk.thunk_p && off == node->thunk.fixed_offset) + break; + if (node) + fndecl = node->decl; + else + return NULL; + } + /* When cgraph node is missing and function is not public, we cannot devirtualize. This can happen in WHOPR when the actual method ends up in other partition, because we found devirtualization |