diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2016-01-15 12:00:24 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2016-01-15 11:00:24 +0000 |
commit | 824ca15e298a60f8ea31e433dd23327f86ee2227 (patch) | |
tree | 27190df53d2330f7499bfc7fc8eff30249dad964 | |
parent | 155768d65f390246004dfe2d6ca22c62d405dc96 (diff) | |
download | gcc-824ca15e298a60f8ea31e433dd23327f86ee2227.zip gcc-824ca15e298a60f8ea31e433dd23327f86ee2227.tar.gz gcc-824ca15e298a60f8ea31e433dd23327f86ee2227.tar.bz2 |
re PR ipa/68148 (Devirtualization only applies to last of multiple successive calls)
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
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ipa-icf.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/devirt-49.C | 20 |
4 files changed, 33 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 006493b..ac14805 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 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. (get_symbol_initial_value): Use it. diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index aaa6a47..ef04c55 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e50e1f9..409c42f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..6beb47b --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-49.C @@ -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" } } */ |