(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
tree-prof/
cold_partition_label.c
       1  /* Test case to check if function foo gets split and the cold function
       2     gets a label.  */
       3  /* { dg-require-effective-target freorder } */
       4  /* { dg-options "-O2 -freorder-blocks-and-partition -save-temps -fdump-tree-optimized" } */
       5  
       6  #ifdef FOR_AUTOFDO_TESTING
       7  #define MAXITER 1000000
       8  #else
       9  #define MAXITER 10000
      10  #endif
      11  
      12  #define SIZE 10000
      13  
      14  const char *sarr[SIZE];
      15  const char *buf_hot;
      16  const char *buf_cold;
      17  
      18  __attribute__((noinline))
      19  void 
      20  foo (int path)
      21  {
      22    int i;
      23    if (path)
      24      {
      25        for (i = 0; i < SIZE; i++)
      26  	sarr[i] = buf_hot;
      27      }
      28    else
      29      {
      30        for (i = 0; i < SIZE; i++)
      31  	sarr[i] = buf_cold;
      32      }
      33  }
      34  
      35  int
      36  main (int argc, char *argv[])
      37  {
      38    int i;
      39    buf_hot =  "hello";
      40    buf_cold = "world";
      41    for (i = 0; i < MAXITER; i++)
      42      foo (argc);
      43    return 0;
      44  }
      45  
      46  /* { dg-final-use-not-autofdo { scan-assembler "foo\[._\]+cold" { target *-*-linux* *-*-gnu* } } } */
      47  /* { dg-final-use-not-autofdo { scan-assembler "size\[ \ta-zA-Z0-0\]+foo\[._\]+cold" { target *-*-linux* *-*-gnu* } } } */
      48  /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */