1 /* { dg-require-effective-target lto } */
2 /* { dg-lto-options { { -flto -O3 -fipa-cp -fipa-cp-clone } } } */
3 /* { dg-lto-do run } */
4
5 /* In order to trigger IPA-CP cloning we have to:
6
7 1. Put the calls in main into a loop; otherwise everything is
8 cold and we would not clone.
9
10 2. Make different foos and bars actually semantically different;
11 otherwise IPA-ICF unified them (as it should).
12
13 */
14
15 volatile int g;
16
17 void __attribute__ ((noipa))
18 use (int v)
19 {
20 g = v;
21 }
22
23 static int __attribute__ ((noinline))
24 foo (int arg)
25 {
26 return 7 * arg;
27 }
28
29 static int __attribute__ ((noinline))
30 bar (int arg)
31 {
32 return arg * arg;
33 }
34
35 extern int __attribute__ ((noinline))
36 entry2 (void);
37
38 int __attribute__ ((noipa))
39 get_opaque_number (void)
40 {
41 return 1;
42 }
43
44 int main (void)
45 {
46 int i;
47 for (i = 0; i < get_opaque_number (); i++)
48 {
49 use (bar (3));
50 use (bar (4));
51 use (foo (5));
52 use (foo (6));
53
54 entry2 ();
55 }
56 return 0;
57 }