aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/func_reorder_gold_plugin_split_functions_1.C
blob: 2f184c3e8d21d6983e1e8b92c0a987cf8c23953b (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Check if the gold function reordering plugin reorders split functions.
   Check if foo is split and the cold section of foo is not next to its hot
   section*/
/* { dg-require-section-exclude "" } */
/* { dg-require-linker-function-reordering-plugin "" } */
/* { dg-require-effective-target freorder } */
/* { dg-options "-O2 -freorder-functions=callgraph -ffunction-sections -freorder-blocks-and-partition --save-temps -Wl,-plugin-opt,file=linker.dump" } */


#define SIZE 10000

const char *sarr[SIZE];
const char *buf_hot;
const char *buf_cold;

__attribute__ ((noinline))
int bar (int *arg)
{
  (*arg)++;
  return 0;
}

__attribute__((noinline))
void 
foo (int path)
{
  int i;
  bar (&path);
  if (path)
    {
      for (i = 0; i < SIZE; i++)
	sarr[i] = buf_hot;
    }
  else
    {
      for (i = 0; i < SIZE; i++)
	sarr[i] = buf_cold;
    }
}

int
main (int argc, char *argv[])
{
  buf_hot =  "hello";
  buf_cold = "world";
  foo (argc);
  return 0;
}

/* { dg-final-use { scan-assembler "\.string \"ColdWeight 0\"" } } */
/* { dg-final-use { scan-assembler "\.section.*\.text\.hot\._Z3fooi" } } */
/* { dg-final-use { scan-assembler "\.section.*\.text\.unlikely\._Z3fooi" } } */
/* { dg-final-use { cleanup-saved-temps } }  */
/* Check if foo and bar are together */
/* { dg-final-use { scan-file linker.dump "Callgraph group :.*\(_Z3fooi _Z3barPi|_Z3barPi _Z3fooi\).*\n" } }  */
/* Check if foo and main are together */
/* { dg-final-use { scan-file linker.dump "Callgraph group :.*\(_Z3fooi main|main _Z3fooi\).*\n" } }  */
/* { dg-final-use { scan-file linker.dump "\.text\.unlikely\._Z3fooi .* split = 1" } } */
/* Check if unlikely sections of foo and bar are together */
/* { dg-final-use { scan-file linker.dump "\(\.text\.unlikely\._Z3fooi\[^\n\]*\n\.text\.unlikely\._Z3barPi\[^\n\]*\n|\.text\.unlikely\._Z3barPi\[^\n\]*\n\.text\.unlikely\._Z3fooi\[^\n\]*\n\)" } }  */
/* Check if likely sections of hot foo and bar are together */
/* { dg-final-use { scan-file linker.dump "\(\.text\._Z3barPi\[^\n\]*\n\.text\.hot\._Z3fooi|\.text\.hot\._Z3fooi\[^\n\]*\n\.text\._Z3barPi\)" } }  */
/* { dg-final-use { remove-build-file "linker.dump" } } */