aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_5.C
blob: dbae8d774c7be41d83ba42eff70105f2e1cf905f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Check if cutting off callgraph and using sort_name_prefix gets all functions laid out
   according to prefixes.   foo_200 is almost as hot as the other foo's but should
   not be grouped with them as it has a different section prefix and sort_name_prefix is
   turned on.  */
/* { dg-require-section-exclude "" } */
/* { dg-require-linker-function-reordering-plugin "" } */
/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -Wl,-plugin-opt,file=linker.dump,-plugin-opt,edge_cutoff=p100,-plugin-opt,sort_name_prefix=yes" } */

int __attribute__ ((noinline, section(".text.unlikely._Z7foo_200v")))
foo_200 ()
{
  return 1;
}

int __attribute__ ((noinline))
foo_100 ()
{
  return 1;
}

int __attribute__ ((noinline))
foo_300 ()
{
  return 1;
}
int main ()
{
  int sum = 0;
  for (int i = 0; i< 200; i++)
    sum += foo_200 ();
  for (int i = 0; i< 100; i++)
    sum += foo_100 ();
  for (int i = 0; i< 300; i++)
    sum += foo_300 ();
  return sum - 600;
}

/* { dg-final-use { scan-file-not linker.dump "Callgraph group" } }  */
/* { dg-final-use { scan-file linker.dump ".text.unlikely._Z7foo_200v entry count = 200 computed = 200 max count = 200" } }  */
/* { dg-final-use { scan-file linker.dump "\.text\.unlikely\._Z7foo_200v.*\n\.text\.*\._Z7foo_100v.*\n\.text\.*\._Z7foo_300v.*\n" } }  */
/* { dg-final-use { remove-build-file "linker.dump" } }  */