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