]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ipa/68148 (Devirtualization only applies to last of multiple successive calls)
authorJan Hubicka <hubicka@ucw.cz>
Fri, 15 Jan 2016 11:00:24 +0000 (12:00 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 15 Jan 2016 11:00:24 +0000 (11:00 +0000)
PR ipa/68148
* ipa-icf.c (sem_function::merge): Virtual functions may become
reachable even if they address is not taken and there are no
idrect calls.
* g++.dg/ipa/devirt-49.C: New testcase.

From-SVN: r232410

gcc/ChangeLog
gcc/ipa-icf.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/devirt-49.C [new file with mode: 0644]

index 006493bb4b077c734b146920b38c3e261deaae15..ac14805ae7625efeffb87961e624893982beca49 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-15  Jan Hubicka  <hubicka@ucw.cz>
+
+       PR ipa/68148
+       * ipa-icf.c (sem_function::merge): Virtual functions may become
+       reachable even if they address is not taken and there are no
+       idrect calls.
+
 2016-01-15  Jan Hubicka  <hubicka@ucw.cz>
 
        * lto-streamer-out.c (subtract_estimated_size): New function.
index aaa6a4766c9510cd2b93f38e51029d2fc2e2c0f1..ef04c559bf406636dc34569cf0ba384b572a74d8 100644 (file)
@@ -1305,6 +1305,7 @@ sem_function::merge (sem_item *alias_item)
 
       /* If all callers was redirected, do not produce wrapper.  */
       if (alias->can_remove_if_no_direct_calls_p ()
+         && !DECL_VIRTUAL_P (alias->decl)
          && !alias->has_aliases_p ())
        {
          create_wrapper = false;
index e50e1f936e1b4e77cdedce2d4890a18edf7a08f5..409c42f01720485be973b0a144c2d32b9328dd3e 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-15  Jan Hubicka <hubicka@ucw.cz>
+
+       PR ipa/68148
+       * g++.dg/ipa/devirt-49.C: New testcase.
+
 2016-01-15  Christian Bruel  <christian.bruel@st.com>
 
        PR target/65837
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-49.C b/gcc/testsuite/g++.dg/ipa/devirt-49.C
new file mode 100644 (file)
index 0000000..6beb47b
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-devirt"  } */
+struct Interface {
+  virtual ~Interface() {}
+  virtual void virtualFunc() = 0;
+  virtual void virtualFunc2() = 0;
+};
+
+struct Concrete : Interface {
+  int counter_;
+  Concrete() : counter_(0) {}
+  void virtualFunc() { counter_++; }
+  void virtualFunc2() { counter_++; }
+};
+
+void test(Interface &c) {
+  c.virtualFunc();
+  c.virtualFunc2();
+}
+/* { dg-final { scan-ipa-dump "2 speculatively devirtualized" "devirt"  } } */