| 1 |
/* Verify that simple virtual calls are inlined even without early |
| 2 |
inlining. */ |
| 3 |
/* { dg-do run { target { nonpic || pie_enabled } } } */ |
| 4 |
/* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining -fno-ipa-cp -fno-ipa-vrp" } */ |
| 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 middleman (class A *obj, int i) |
| 43 |
{ |
| 44 |
return obj->foo (i); |
| 45 |
} |
| 46 |
|
| 47 |
int __attribute__ ((noinline,noclone)) get_input(void) |
| 48 |
{ |
| 49 |
return 1; |
| 50 |
} |
| 51 |
|
| 52 |
int main (int argc, char *argv[]) |
| 53 |
{ |
| 54 |
class B b; |
| 55 |
int i; |
| 56 |
|
| 57 |
for (i = 0; i < get_input (); i++) |
| 58 |
if (middleman (&b, get_input ()) != 3) |
| 59 |
abort (); |
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
/* { dg-final { scan-ipa-dump "B::foo\[^\\n\]*inline copy in int main" "inline" } } */ |