1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 
4 /* The ipa-split pass pulls the body of the if(!x) block
5    into a separate function to make foo a better inlining
6    candidate.  Make sure this new function isn't also run
7    as a static constructor.  */
8 
9 #include <stdlib.h>
10 
11 int x, y;
12 
13 void __attribute__((noinline))
bar(void)14 bar(void)
15 {
16   y++;
17 }
18 
19 void __attribute__((constructor))
foo(void)20 foo(void)
21 {
22   if (!x)
23     {
24       bar();
25       y++;
26     }
27 }
28 
main()29 int main()
30 {
31   x = 1;
32   foo();
33   foo();
34   if (y != 2)
35     abort();
36   exit(0);
37 }
38