From: Jan Hubicka Date: Wed, 5 Feb 2014 00:52:53 +0000 (+0100) Subject: ipa-prop.c (detect_type_change): Shor circuit testing of type changes on THIS pointer. X-Git-Tag: releases/gcc-4.9.0~1090 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bf2a588d4f65587e9678c8a5e068ebd92110f85;p=thirdparty%2Fgcc.git ipa-prop.c (detect_type_change): Shor circuit testing of type changes on THIS pointer. * ipa-prop.c (detect_type_change): Shor circuit testing of type changes on THIS pointer. * g++.dg/ipa/devirrt-22.C: Fix template. From-SVN: r207495 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f15e84739ede..47b8a7c5f322 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-02-04 Jan Hubicka + + * ipa-prop.c (detect_type_change): Shor circuit testing of + type changes on THIS pointer. + 2014-02-04 John David Anglin PR target/59777 diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 69566e9f3a88..bc23da656b4d 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -688,6 +688,19 @@ detect_type_change (tree arg, tree base, tree comp_type, gimple call, || !BINFO_VTABLE (TYPE_BINFO (comp_type))) return false; + /* C++ methods are not allowed to change THIS pointer unless they + are constructors or destructors. */ + if (TREE_CODE (base) == MEM_REF + && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME + && SSA_NAME_IS_DEFAULT_DEF (TREE_OPERAND (base, 0)) + && TREE_CODE (SSA_NAME_VAR (TREE_OPERAND (base, 0))) == PARM_DECL + && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE + && !DECL_CXX_CONSTRUCTOR_P (current_function_decl) + && !DECL_CXX_DESTRUCTOR_P (current_function_decl) + && (SSA_NAME_VAR (TREE_OPERAND (base, 0)) + == DECL_ARGUMENTS (current_function_decl))) + return false; + ao_ref_init (&ao, arg); ao.base = base; ao.offset = offset; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c28041dfc24..4409d870363a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-02-04 Jan Hubicka + + * g++.dg/ipa/devirrt-22.C: Fix template. + 2014-02-04 Marek Polacek PR c/60036 diff --git a/gcc/testsuite/g++.dg/ipa/devirt-22.C b/gcc/testsuite/g++.dg/ipa/devirt-22.C index 8b8279ae0f23..37e766945a39 100644 --- a/gcc/testsuite/g++.dg/ipa/devirt-22.C +++ b/gcc/testsuite/g++.dg/ipa/devirt-22.C @@ -37,5 +37,5 @@ void update_sources() { /* Note that we miss one devirtualization because we are not able to track the vtbl store in destructor. Previously we devirtualized to C::m_fn1 instead of B::m_fn1. */ -/* { dg-final { scan-tree-dump-times "Discovered a virtual call to a known target" 1 "cp" } } */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "cp" } } */ /* { dg-final { cleanup-ipa-dump "cp" } } */