| 1 |
/* Verify that simple indirect calls are inlined even without early |
| 2 |
inlining.. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining" } */ |
| 5 |
/* { dg-add-options bind_pic_locally } */ |
| 6 |
|
| 7 |
extern void non_existent (const char *, int); |
| 8 |
|
| 9 |
class String |
| 10 |
{ |
| 11 |
private: |
| 12 |
const char *data; |
| 13 |
|
| 14 |
public: |
| 15 |
String (const char *d) : data(d) |
| 16 |
{} |
| 17 |
|
| 18 |
int funcOne (int delim) const; |
| 19 |
int printStuffTwice (int delim) const; |
| 20 |
}; |
| 21 |
|
| 22 |
|
| 23 |
int String::funcOne (int delim) const |
| 24 |
{ |
| 25 |
int i; |
| 26 |
for (i = 0; i < delim; i++) |
| 27 |
non_existent(data, i); |
| 28 |
|
| 29 |
return 1; |
| 30 |
} |
| 31 |
|
| 32 |
extern int global; |
| 33 |
|
| 34 |
int docalling (int c, int (String::* f)(int delim) const) |
| 35 |
{ |
| 36 |
String S ("muhehehe"); |
| 37 |
|
| 38 |
if (c > 2) |
| 39 |
global = 3; |
| 40 |
else |
| 41 |
global = 5; |
| 42 |
|
| 43 |
return (S.*f)(4); |
| 44 |
} |
| 45 |
|
| 46 |
int __attribute__ ((noinline,noclone)) get_input (void) |
| 47 |
{ |
| 48 |
return 1; |
| 49 |
} |
| 50 |
|
| 51 |
int main (int argc, char *argv[]) |
| 52 |
{ |
| 53 |
int i = 0; |
| 54 |
while (i < 1000) |
| 55 |
i += docalling (get_input (), &String::funcOne); |
| 56 |
non_existent ("done", i); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
/* { dg-final { scan-ipa-dump "String::funcOne\[^\\n\]*inline copy in int main" "inline" } } */ |