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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* Verify that ipa-co can convert virtual calls to direct ones even
2
   when a typecast to an ancestor is involved along the way.  */
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
  virtual int foo (int i);
13
};
14
 
15
class B : public A
16
{
17
public:
18
  virtual int foo (int i);
19
};
20
 
21
class C : public A
22
{
23
public:
24
  virtual int foo (int i);
25
};
26
 
27
int A::foo (int i)
28
{
29
  return i + 1;
30
}
31
 
32
int B::foo (int i)
33
{
34
  return i + 2;
35
}
36
 
37
int C::foo (int i)
38
{
39
  return i + 3;
40
}
41
 
42
int __attribute__ ((noinline,noclone)) get_input(void)
43
{
44
  return 1;
45
}
46
 
47
static int middleman_1 (class A *obj, int i)
48
{
49
  return obj->foo (i);
50
}
51
 
52
static int middleman_2 (class B *obj, int i)
53
{
54
  return middleman_1 (obj, i);
55
}
56
 
57
int main (int argc, char *argv[])
58
{
59
  class B b;
60
  if (middleman_2 (&b, get_input ()) != 3)
61
    abort ();
62
  return 0;
63
}
64
 
65
/* { dg-final { scan-ipa-dump "Discovered a virtual call to a known target.*B::foo"  "cp"  } } */
66
/* { dg-final { scan-tree-dump-times "OBJ_TYPE_REF" 0 "optimized"} } */
67
/* { dg-final { cleanup-ipa-dump "cp" } } */
68
/* { 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.