view gcc/testsuite/g++.dg/ipa/devirt-g-1.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
line wrap: on
line source

// { dg-do compile }
// { dg-options "-O2 -fdump-ipa-cp -fno-ipa-icf -fdump-tree-optimized" }

struct S { S(); virtual void xyzzy(); void otherstuff(); };
struct R { int a; S s; R(); };
S s;
R r;

void S::xyzzy ()
{
  otherstuff ();
  otherstuff ();
}

static void __attribute__ ((noinline)) foo(S *p) { p->xyzzy(); }
void bar() {foo(&s); }

static void __attribute__ ((noinline)) foh(S *p) { p->xyzzy(); }
void bah() {foh(&r.s); }

/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*S::xyzzy" "cp"  } } */
/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */