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