annotate gcc/testsuite/gcc.dg/tree-prof/section-attr-3.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Checks for a bug where static data with a section attribute within a
kono
parents:
diff changeset
2 function would stop the function being partitioned into hot and cold
kono
parents:
diff changeset
3 blocks. */
kono
parents:
diff changeset
4 /* { dg-require-effective-target freorder } */
kono
parents:
diff changeset
5 /* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 #define SIZE 10000
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 #define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 const char *sarr[SIZE];
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
12 #ifdef __APPLE__
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
13 const char *buf_hot __attribute__ ((section ("__DATA,__data")));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
14 #else
111
kono
parents:
diff changeset
15 const char *buf_hot __attribute__ ((section (".data")));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
16 #endif
111
kono
parents:
diff changeset
17 const char *buf_cold;
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 void foo (int path);
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 int
kono
parents:
diff changeset
22 main (int argc, char *argv[])
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 int i;
kono
parents:
diff changeset
25 buf_hot = "hello";
kono
parents:
diff changeset
26 buf_cold = "world";
kono
parents:
diff changeset
27 for (i = 0; i < 1000000; i++)
kono
parents:
diff changeset
28 foo (argc);
kono
parents:
diff changeset
29 return 0;
kono
parents:
diff changeset
30 }
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 void NOINLINE
kono
parents:
diff changeset
34 foo (int path)
kono
parents:
diff changeset
35 {
kono
parents:
diff changeset
36 int i;
kono
parents:
diff changeset
37 if (path)
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 for (i = 0; i < SIZE; i++)
kono
parents:
diff changeset
40 sarr[i] = buf_hot;
kono
parents:
diff changeset
41 }
kono
parents:
diff changeset
42 else
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 for (i = 0; i < SIZE; i++)
kono
parents:
diff changeset
45 sarr[i] = buf_cold;
kono
parents:
diff changeset
46 }
kono
parents:
diff changeset
47 }
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 /* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50 /* { dg-final-use { scan-assembler "\.section\[\t \]*__TEXT,__text_cold\.\*\[\\n\\r\]+_foo\.cold\.0:" { target *-*-darwin* } } } */