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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that IPA-CP can do devirtualization even if the virtual call
2
   comes from a method that has been early-inlined into a descendant.  */
3
/* { dg-do run } */
4
/* { dg-options "-O3 -fdump-ipa-cp"  } */
5
 
6
extern "C" void abort (void);
7
 
8
class Distraction
9
{
10
public:
11
  float f;
12
  double d;
13
  Distraction ()
14
  {
15
    f = 8.3;
16
    d = 10.2;
17
  }
18
  virtual float bar (float z);
19
};
20
 
21
class A
22
{
23
public:
24
  int data;
25
  virtual int foo (int i);
26
  int middleman_1 (int i);
27
};
28
 
29
 
30
class B : public Distraction, public A
31
{
32
public:
33
  virtual int foo (int i);
34
  int middleman_2 (int i);
35
  __attribute__ ((noinline)) B();
36
};
37
 
38
float Distraction::bar (float z)
39
{
40
  f += z;
41
  return f/2;
42
}
43
 
44
int A::foo (int i)
45
{
46
  return i + 1;
47
}
48
 
49
int B::foo (int i)
50
{
51
  return i + 2;
52
}
53
 
54
int __attribute__ ((noinline,noclone)) get_input(void)
55
{
56
  return 1;
57
}
58
 
59
int inline __attribute__ ((always_inline))
60
A::middleman_1 (int i)
61
{
62
  return this->foo (i);
63
}
64
 
65
int __attribute__ ((noinline))
66
B::middleman_2 (int i)
67
{
68
  return this->middleman_1 (i);
69
}
70
 
71
B::B ()
72
{
73
}
74
 
75
int main (int argc, char *argv[])
76
{
77
  class B b;
78
  int i;
79
 
80
  for (i = 0; i < get_input(); i++)
81
    if (b.middleman_2 (get_input ()) != 3)
82
      abort ();
83
  return 0;
84
}
85
 
86
/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */
87
/* { dg-final { cleanup-ipa-dump "cp" } } */

powered by: WebSVN 2.1.0

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