view gcc/testsuite/g++.dg/tree-prof/partition1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-require-effective-target freorder } */
/* { dg-options "-O2 -freorder-blocks-and-partition" } */

struct A { A () __attribute__((noinline)); ~A () __attribute__((noinline)); };
A::A () { asm volatile ("" : : : "memory"); }
A::~A () { asm volatile ("" : : : "memory"); }

int bar () __attribute__((noinline));
void foo () __attribute__((noinline));

volatile int k, l;

int bar (int i)
{
  void *p = __builtin_alloca (i);
  asm volatile ("" : : "r" (i), "r" (p) : "memory");
  if (k) throw 6;
  return ++l;
}

void foo ()
{
  A a;
  try {
    A b;
    int i = bar (5);
    try { throw 6; } catch (int) {}
    if (__builtin_expect (i < 4500, 0)) {
      bar (7);
      try { bar (8); } catch (long) {}
      bar (10);
      if (__builtin_expect (i < 0, 0)) {
	try { bar (12); } catch (...) {}
	bar (16);
	bar (122);
      } else {
	try { bar (bar (7)); } catch (int) {}
      }
    } else {
      try { bar (bar (bar (9))); } catch (...) {}
      bar (5);
    }
  } catch (...) {
  }
}

int
main ()
{
  int i;
  for (i = 0; i < 10000; i++)
    foo ();
}