| 1 |
/* { dg-options "-O2 -fdump-tree-modref1 -fdump-tree-optimized" } */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
int c; |
| 4 |
__attribute__ ((noinline)) |
| 5 |
int *test (int *b) |
| 6 |
{ |
| 7 |
c++; |
| 8 |
return *b ? &c : 0; |
| 9 |
} |
| 10 |
__attribute__ ((noinline, pure)) |
| 11 |
int *pure_test (int *b) |
| 12 |
{ |
| 13 |
return *b && c ? &c : 0; |
| 14 |
} |
| 15 |
__attribute__ ((noinline, const)) |
| 16 |
int *const_test (int *b) |
| 17 |
{ |
| 18 |
return b ? &c : 0; |
| 19 |
} |
| 20 |
void escape (int *); |
| 21 |
|
| 22 |
int test2() |
| 23 |
{ |
| 24 |
int a = 42; |
| 25 |
escape (test (&a)); |
| 26 |
escape (pure_test (&a)); |
| 27 |
escape (const_test (&a)); |
| 28 |
return a; |
| 29 |
} |
| 30 |
/* Flags for normal call. */ |
| 31 |
/* { dg-final { scan-tree-dump "parm 0 flags: no_direct_clobber no_indirect_clobber no_direct_escape no_indirect_escape not_returned_directly not_returned_indirectly no_indirect_read" "modref1" } } */ |
| 32 |
/* Flags for pure call. */ |
| 33 |
/* { dg-final { scan-tree-dump "parm 0 flags: not_returned_directly not_returned_indirectly no_indirect_read" "modref1" } } */ |
| 34 |
/* Flags for const call. */ |
| 35 |
/* { dg-final { scan-tree-dump "parm 0 flags: not_returned_directly" "modref1" } } */ |
| 36 |
/* Overall we want to make "int a" non escaping. */ |
| 37 |
/* { dg-final { scan-tree-dump "return 42" "optimized" } } */ |