From 167832599913878e6c432047d270691dee0e6c7d Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 1 Sep 2013 17:06:40 +0000 Subject: [PATCH] * g++.dg/ipa/devirt-15.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202153 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/ipa/devirt-15.C | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/devirt-15.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c42a3dae39c..7ff5882d6b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-09-01 Jan Hubicka + + * g++.dg/ipa/devirt-15.C: New testcase. + 2013-09-01 Eric Botcazou * gnat.dg/specs/linker_alias.ads: Skip on Darwin. diff --git a/gcc/testsuite/g++.dg/ipa/devirt-15.C b/gcc/testsuite/g++.dg/ipa/devirt-15.C new file mode 100644 index 00000000000..f9cd3ae5a67 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-15.C @@ -0,0 +1,40 @@ +/* Check that we speculatively devirutalize call to FOO to B::foo becuase + A is noreturn. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-devirt" } */ +class A { +public: + virtual int foo(void) + { + throw (1); + return 0; + } +}; + + +class B : public A { +public: + virtual int foo(void); +}; + +int +B::foo(void) +{ + return 1; +} +class A a, *b=&a; +void +m(void) +{ + b->foo(); +} +main() +{ + m(); +} + +/* { dg-final { scan-ipa-dump "Speculatively devirtualizing call" "devirt"} } */ +/* { dg-final { cleanup-ipa-dump "devirt" } } */ +/* Match if (PROF_6 == foo) to verify that the speculation survived. */ +/* { dg-final { scan-tree-dump "== foo" "optimized"} } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ -- 2.11.4.GIT