libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-prof / section-attr-1.c
blob5376de14a2fc7a2b170c119e91ab6f427dd33dd5
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 #ifdef FOR_AUTOFDO_TESTING
7 #define MAXITER 1000000
8 #else
9 #define MAXITER 10000
10 #endif
12 #define SIZE 10000
14 #define NOINLINE __attribute__((noinline)) __attribute__ ((noclone))
16 const char *sarr[SIZE];
17 const char *buf_hot;
18 const char *buf_cold;
20 void foo (int path);
22 #ifdef __APPLE__
23 __attribute__ ((section ("__TEXT,__text")))
24 #else
25 __attribute__((section(".text")))
26 #endif
27 int
28 main (int argc, char *argv[])
30 int i;
31 buf_hot = "hello";
32 buf_cold = "world";
33 for (i = 0; i < MAXITER; i++)
34 foo (argc);
35 return 0;
39 void NOINLINE
40 foo (int path)
42 int i;
43 if (path)
45 for (i = 0; i < SIZE; i++)
46 sarr[i] = buf_hot;
48 else
50 for (i = 0; i < SIZE; i++)
51 sarr[i] = buf_cold;
55 /* { dg-final-use-not-autofdo { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold" { target *-*-linux* *-*-gnu* } } } */
56 /* { dg-final-use-not-autofdo { scan-assembler {.section[\t ]*__TEXT,__text_cold[^\n]*[\n\r]+_foo.cold:} { target *-*-darwin* } } } */