OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [ipa/] [devirt-c-8.C] - Blame information for rev 715

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that ipa-cp correctly detects the dynamic type of an object
2
   under construction when doing devirtualization.  */
3
/* { dg-do run } */
4
/* { dg-options "-O3 -fno-early-inlining -fno-inline -fdump-ipa-cp -fdump-tree-optimized"  } */
5
 
6
extern "C" void abort (void);
7
 
8
class A
9
{
10
public:
11
  int data;
12
  A();
13
  virtual int foo (int i);
14
};
15
 
16
class B : public A
17
{
18
public:
19
  B();
20
  virtual int foo (int i);
21
};
22
 
23
class C : public A
24
{
25
public:
26
  virtual int foo (int i);
27
};
28
 
29
int A::foo (int i)
30
{
31
  return i + 1;
32
}
33
 
34
int B::foo (int i)
35
{
36
  return i + 2;
37
}
38
 
39
int C::foo (int i)
40
{
41
  return i + 3;
42
}
43
 
44
static int __attribute__ ((noinline))
45
middleman (class A *obj, int i)
46
{
47
  return obj->foo (i);
48
}
49
 
50
int __attribute__ ((noinline,noclone)) get_input(void)
51
{
52
  return 1;
53
}
54
 
55
inline __attribute__ ((always_inline)) A::A ()
56
{
57
  if (middleman (this, get_input ()) != 2)
58
    abort ();
59
}
60
 
61
inline __attribute__ ((always_inline)) B::B ()
62
{
63
}
64
 
65
static void bah ()
66
{
67
  class B b;
68
}
69
 
70
int main (int argc, char *argv[])
71
{
72
  int i;
73
 
74
  for (i = 0; i < 10; i++)
75
    bah ();
76
  return 0;
77
}
78
 
79
/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*A::foo"  "cp"  } } */
80
/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
81
/* { dg-final { cleanup-ipa-dump "cp" } } */
82
/* { dg-final { cleanup-tree-dump "optimized" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.