diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2014-02-05 01:52:53 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2014-02-05 00:52:53 +0000 |
commit | 4bf2a588d4f65587e9678c8a5e068ebd92110f85 (patch) | |
tree | e585a48e997b5f785feaf19216a43ef36487ea3e /gcc | |
parent | d92f4df01a7c59cea958574a7d716661bb96a35b (diff) | |
download | gcc-4bf2a588d4f65587e9678c8a5e068ebd92110f85.zip gcc-4bf2a588d4f65587e9678c8a5e068ebd92110f85.tar.gz gcc-4bf2a588d4f65587e9678c8a5e068ebd92110f85.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/devirt-22.C | 2 |
4 files changed, 23 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f15e847..47b8a7c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-02-04 Jan Hubicka <hubicka@ucw.cz> + + * ipa-prop.c (detect_type_change): Shor circuit testing of + type changes on THIS pointer. + 2014-02-04 John David Anglin <danglin@gcc.gnu.org> PR target/59777 diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 69566e9..bc23da65 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 4c28041..4409d87 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-02-04 Jan Hubicka <hubicka@ucw.cz> + + * g++.dg/ipa/devirrt-22.C: Fix template. + 2014-02-04 Marek Polacek <polacek@redhat.com> PR c/60036 diff --git a/gcc/testsuite/g++.dg/ipa/devirt-22.C b/gcc/testsuite/g++.dg/ipa/devirt-22.C index 8b8279a..37e7669 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" } } */ |