PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-prof / section-attr-1.c
blobee6662ea6e553c2d0b9f9fca4c0c386c80ee96ef
1 /* Checks for a bug where a function with a section attribute would prevent
2 all later functions from being partitioned into hot and cold blocks. */
3 /* { dg-require-effective-target freorder } */
4 /* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */
6 #define SIZE 10000
8 #define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
10 const char *sarr[SIZE];
11 const char *buf_hot;
12 const char *buf_cold;
14 void foo (int path);
16 __attribute__((section(".text")))
17 int
18 main (int argc, char *argv[])
20 int i;
21 buf_hot = "hello";
22 buf_cold = "world";
23 for (i = 0; i < 1000000; i++)
24 foo (argc);
25 return 0;
29 void NOINLINE
30 foo (int path)
32 int i;
33 if (path)
35 for (i = 0; i < SIZE; i++)
36 sarr[i] = buf_hot;
38 else
40 for (i = 0; i < SIZE; i++)
41 sarr[i] = buf_cold;
45 /* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */