]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-prop.c (detect_type_change): Shor circuit testing of type changes on THIS pointer.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 5 Feb 2014 00:52:53 +0000 (01:52 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 5 Feb 2014 00:52:53 +0000 (00:52 +0000)
* 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

gcc/ChangeLog
gcc/ipa-prop.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/devirt-22.C

index f15e84739ede9f8fb334c5d0e557bcbea8d0c2bb..47b8a7c5f322d747dedc32305192bd8e9dd39933 100644 (file)
@@ -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
index 69566e9f3a88b413084c2e8c41311c176fea5e6f..bc23da656b4d0079ee38b890b79dadd33384d353 100644 (file)
@@ -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;
index 4c28041dfc2417df6a3494d10507a957b4598cb0..4409d870363a9ef682ef42ad388dffecf299d25a 100644 (file)
@@ -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
index 8b8279ae0f23c6fe080c8dcec6424a9e0024be4c..37e766945a39ddb403809a32f251c84a3d152d80 100644 (file)
@@ -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" } } */