Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/ipa/devirt-42.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 84e7813d76e9 |
children |
line wrap: on
line source
/* { dg-do compile } */ /* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining -fdump-tree-optimized" } */ struct A { virtual int foo () {return 1;} int bar () {return foo();} int barbar (); }; namespace { struct B:A {virtual int foo () {return 2;} int barbar () {return bar();}}; } int A::barbar() { return static_cast<B*>(this)->barbar(); } int main() { struct B b; struct A *a = &b; return a->barbar (); } /* Inlining everything into main makes type clear from type of variable b. However devirtualization is also possible for offline copy of A::barbar. Invoking B's barbar makes it clear the type is at least B and B is an anonymous namespace type and therefore we know it has no derivations. */ /* { dg-final { scan-ipa-dump "First type is base of second" "inline" } } */ /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 2 "inline" } } */ /* Verify that speculation is optimized by late optimizers. */ /* { dg-final { scan-tree-dump-times "return 2" 3 "optimized" } } */ /* { dg-final { scan-tree-dump-not "OBJ_TYPE_REF" "optimized" } } */