annotate gcc/lto/lto.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Top-level LTO routines.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2009-2020 Free Software Foundation, Inc.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by CodeSourcery, Inc.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "system.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "coretypes.h"
111
kono
parents: 67
diff changeset
24 #include "tm.h"
kono
parents: 67
diff changeset
25 #include "function.h"
kono
parents: 67
diff changeset
26 #include "bitmap.h"
kono
parents: 67
diff changeset
27 #include "basic-block.h"
kono
parents: 67
diff changeset
28 #include "tree.h"
kono
parents: 67
diff changeset
29 #include "gimple.h"
kono
parents: 67
diff changeset
30 #include "cfghooks.h"
kono
parents: 67
diff changeset
31 #include "alloc-pool.h"
kono
parents: 67
diff changeset
32 #include "tree-pass.h"
kono
parents: 67
diff changeset
33 #include "tree-streamer.h"
kono
parents: 67
diff changeset
34 #include "cgraph.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "opts.h"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #include "toplev.h"
111
kono
parents: 67
diff changeset
37 #include "stor-layout.h"
kono
parents: 67
diff changeset
38 #include "symbol-summary.h"
kono
parents: 67
diff changeset
39 #include "tree-vrp.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #include "ipa-prop.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
41 #include "debug.h"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 #include "lto.h"
111
kono
parents: 67
diff changeset
43 #include "lto-section-names.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
44 #include "splay-tree.h"
111
kono
parents: 67
diff changeset
45 #include "lto-partition.h"
kono
parents: 67
diff changeset
46 #include "context.h"
kono
parents: 67
diff changeset
47 #include "pass_manager.h"
kono
parents: 67
diff changeset
48 #include "ipa-fnsummary.h"
kono
parents: 67
diff changeset
49 #include "ipa-utils.h"
kono
parents: 67
diff changeset
50 #include "gomp-constants.h"
kono
parents: 67
diff changeset
51 #include "lto-symtab.h"
kono
parents: 67
diff changeset
52 #include "stringpool.h"
kono
parents: 67
diff changeset
53 #include "fold-const.h"
kono
parents: 67
diff changeset
54 #include "attribs.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
55 #include "builtins.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
56 #include "lto-common.h"
111
kono
parents: 67
diff changeset
57
kono
parents: 67
diff changeset
58
kono
parents: 67
diff changeset
59 /* Number of parallel tasks to run, -1 if we want to use GNU Make jobserver. */
kono
parents: 67
diff changeset
60 static int lto_parallelism;
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
62 /* Return true when NODE has a clone that is analyzed (i.e. we need
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
63 to load its body even if the node itself is not needed). */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
64
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
65 static bool
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
66 has_analyzed_clone_p (struct cgraph_node *node)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
67 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
68 struct cgraph_node *orig = node;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
69 node = node->clones;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
70 if (node)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
71 while (node != orig)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
72 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
73 if (node->analyzed)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
74 return true;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
75 if (node->clones)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
76 node = node->clones;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
77 else if (node->next_sibling_clone)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
78 node = node->next_sibling_clone;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
79 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
80 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
81 while (node != orig && !node->next_sibling_clone)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
82 node = node->clone_of;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
83 if (node != orig)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
84 node = node->next_sibling_clone;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
85 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
86 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
87 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
88 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
89
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
90 /* Read the function body for the function associated with NODE. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 lto_materialize_function (struct cgraph_node *node)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 {
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 tree decl;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 decl = node->decl;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
98 /* Read in functions with body (analyzed nodes)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
99 and also functions that are needed to produce virtual clones. */
111
kono
parents: 67
diff changeset
100 if ((node->has_gimple_body_p () && node->analyzed)
kono
parents: 67
diff changeset
101 || node->used_as_abstract_origin
kono
parents: 67
diff changeset
102 || has_analyzed_clone_p (node))
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
103 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
104 /* Clones don't need to be read. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
105 if (node->clone_of)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
106 return;
111
kono
parents: 67
diff changeset
107 if (DECL_FUNCTION_PERSONALITY (decl) && !first_personality_decl)
kono
parents: 67
diff changeset
108 first_personality_decl = DECL_FUNCTION_PERSONALITY (decl);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
109 /* If the file contains a function with a language specific EH
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
110 personality set or with EH enabled initialize the backend EH
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
111 machinery. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 if (DECL_FUNCTION_PERSONALITY (decl)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
113 || opt_for_fn (decl, flag_exceptions))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
114 lto_init_eh ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 /* Let the middle end know about the function. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 rest_of_decl_compilation (decl, 1, 0);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
121 /* Materialize all the bodies for all the nodes in the callgraph. */
111
kono
parents: 67
diff changeset
122
kono
parents: 67
diff changeset
123 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
124 materialize_cgraph (void)
111
kono
parents: 67
diff changeset
125 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
126 struct cgraph_node *node;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
127 timevar_id_t lto_timer;
111
kono
parents: 67
diff changeset
128
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
129 if (!quiet_flag)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
130 fprintf (stderr,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
131 flag_wpa ? "Materializing decls:" : "Reading function bodies:");
111
kono
parents: 67
diff changeset
132
kono
parents: 67
diff changeset
133
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
134 FOR_EACH_FUNCTION (node)
111
kono
parents: 67
diff changeset
135 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
136 if (node->lto_file_data)
111
kono
parents: 67
diff changeset
137 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
138 lto_materialize_function (node);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
139 lto_stats.num_input_cgraph_nodes++;
111
kono
parents: 67
diff changeset
140 }
kono
parents: 67
diff changeset
141 }
kono
parents: 67
diff changeset
142
kono
parents: 67
diff changeset
143
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
144 /* Start the appropriate timer depending on the mode that we are
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
145 operating in. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
146 lto_timer = (flag_wpa) ? TV_WHOPR_WPA
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
147 : (flag_ltrans) ? TV_WHOPR_LTRANS
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
148 : TV_LTO;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
149 timevar_push (lto_timer);
111
kono
parents: 67
diff changeset
150
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
151 current_function_decl = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
152 set_cfun (NULL);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
153
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
154 if (!quiet_flag)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
155 fprintf (stderr, "\n");
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
157 timevar_pop (lto_timer);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
111
kono
parents: 67
diff changeset
160 /* Actually stream out ENCODER into TEMP_FILENAME. */
kono
parents: 67
diff changeset
161
kono
parents: 67
diff changeset
162 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
163 stream_out (char *temp_filename, lto_symtab_encoder_t encoder, int part)
111
kono
parents: 67
diff changeset
164 {
kono
parents: 67
diff changeset
165 lto_file *file = lto_obj_file_open (temp_filename, true);
kono
parents: 67
diff changeset
166 if (!file)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
167 fatal_error (input_location, "%<lto_obj_file_open()%> failed");
111
kono
parents: 67
diff changeset
168 lto_set_current_out_file (file);
kono
parents: 67
diff changeset
169
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
170 gcc_assert (!dump_file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
171 streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL, part);
111
kono
parents: 67
diff changeset
172 ipa_write_optimization_summaries (encoder);
kono
parents: 67
diff changeset
173
kono
parents: 67
diff changeset
174 free (CONST_CAST (char *, file->filename));
kono
parents: 67
diff changeset
175
kono
parents: 67
diff changeset
176 lto_set_current_out_file (NULL);
kono
parents: 67
diff changeset
177 lto_obj_file_close (file);
kono
parents: 67
diff changeset
178 free (file);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
179 if (streamer_dump_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
180 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
181 dump_end (TDI_lto_stream_out, streamer_dump_file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
182 streamer_dump_file = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
183 }
111
kono
parents: 67
diff changeset
184 }
kono
parents: 67
diff changeset
185
kono
parents: 67
diff changeset
186 /* Wait for forked process and signal errors. */
kono
parents: 67
diff changeset
187 #ifdef HAVE_WORKING_FORK
kono
parents: 67
diff changeset
188 static void
kono
parents: 67
diff changeset
189 wait_for_child ()
kono
parents: 67
diff changeset
190 {
kono
parents: 67
diff changeset
191 int status;
kono
parents: 67
diff changeset
192 do
kono
parents: 67
diff changeset
193 {
kono
parents: 67
diff changeset
194 #ifndef WCONTINUED
kono
parents: 67
diff changeset
195 #define WCONTINUED 0
kono
parents: 67
diff changeset
196 #endif
kono
parents: 67
diff changeset
197 int w = waitpid (0, &status, WUNTRACED | WCONTINUED);
kono
parents: 67
diff changeset
198 if (w == -1)
kono
parents: 67
diff changeset
199 fatal_error (input_location, "waitpid failed");
kono
parents: 67
diff changeset
200
kono
parents: 67
diff changeset
201 if (WIFEXITED (status) && WEXITSTATUS (status))
kono
parents: 67
diff changeset
202 fatal_error (input_location, "streaming subprocess failed");
kono
parents: 67
diff changeset
203 else if (WIFSIGNALED (status))
kono
parents: 67
diff changeset
204 fatal_error (input_location,
kono
parents: 67
diff changeset
205 "streaming subprocess was killed by signal");
kono
parents: 67
diff changeset
206 }
kono
parents: 67
diff changeset
207 while (!WIFEXITED (status) && !WIFSIGNALED (status));
kono
parents: 67
diff changeset
208 }
kono
parents: 67
diff changeset
209 #endif
kono
parents: 67
diff changeset
210
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
211 static void
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 stream_out_partitions_1 (char *temp_filename, int blen, int min, int max)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214 /* Write all the nodes in SET. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 for (int p = min; p < max; p ++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217 sprintf (temp_filename + blen, "%u.o", p);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
218 stream_out (temp_filename, ltrans_partitions[p]->encoder, p);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219 ltrans_partitions[p]->encoder = NULL;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
221 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
222
111
kono
parents: 67
diff changeset
223 /* Stream out ENCODER into TEMP_FILENAME
kono
parents: 67
diff changeset
224 Fork if that seems to help. */
kono
parents: 67
diff changeset
225
kono
parents: 67
diff changeset
226 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 stream_out_partitions (char *temp_filename, int blen, int min, int max,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228 bool ARG_UNUSED (last))
111
kono
parents: 67
diff changeset
229 {
kono
parents: 67
diff changeset
230 #ifdef HAVE_WORKING_FORK
kono
parents: 67
diff changeset
231 static int nruns;
kono
parents: 67
diff changeset
232
kono
parents: 67
diff changeset
233 if (lto_parallelism <= 1)
kono
parents: 67
diff changeset
234 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235 stream_out_partitions_1 (temp_filename, blen, min, max);
111
kono
parents: 67
diff changeset
236 return;
kono
parents: 67
diff changeset
237 }
kono
parents: 67
diff changeset
238
kono
parents: 67
diff changeset
239 /* Do not run more than LTO_PARALLELISM streamings
kono
parents: 67
diff changeset
240 FIXME: we ignore limits on jobserver. */
kono
parents: 67
diff changeset
241 if (lto_parallelism > 0 && nruns >= lto_parallelism)
kono
parents: 67
diff changeset
242 {
kono
parents: 67
diff changeset
243 wait_for_child ();
kono
parents: 67
diff changeset
244 nruns --;
kono
parents: 67
diff changeset
245 }
kono
parents: 67
diff changeset
246 /* If this is not the last parallel partition, execute new
kono
parents: 67
diff changeset
247 streaming process. */
kono
parents: 67
diff changeset
248 if (!last)
kono
parents: 67
diff changeset
249 {
kono
parents: 67
diff changeset
250 pid_t cpid = fork ();
kono
parents: 67
diff changeset
251
kono
parents: 67
diff changeset
252 if (!cpid)
kono
parents: 67
diff changeset
253 {
kono
parents: 67
diff changeset
254 setproctitle ("lto1-wpa-streaming");
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 stream_out_partitions_1 (temp_filename, blen, min, max);
111
kono
parents: 67
diff changeset
256 exit (0);
kono
parents: 67
diff changeset
257 }
kono
parents: 67
diff changeset
258 /* Fork failed; lets do the job ourseleves. */
kono
parents: 67
diff changeset
259 else if (cpid == -1)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260 stream_out_partitions_1 (temp_filename, blen, min, max);
111
kono
parents: 67
diff changeset
261 else
kono
parents: 67
diff changeset
262 nruns++;
kono
parents: 67
diff changeset
263 }
kono
parents: 67
diff changeset
264 /* Last partition; stream it and wait for all children to die. */
kono
parents: 67
diff changeset
265 else
kono
parents: 67
diff changeset
266 {
kono
parents: 67
diff changeset
267 int i;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 stream_out_partitions_1 (temp_filename, blen, min, max);
111
kono
parents: 67
diff changeset
269 for (i = 0; i < nruns; i++)
kono
parents: 67
diff changeset
270 wait_for_child ();
kono
parents: 67
diff changeset
271 }
kono
parents: 67
diff changeset
272 asm_nodes_output = true;
kono
parents: 67
diff changeset
273 #else
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
274 stream_out_partitions_1 (temp_filename, blen, min, max);
111
kono
parents: 67
diff changeset
275 #endif
kono
parents: 67
diff changeset
276 }
kono
parents: 67
diff changeset
277
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
278 /* Write all output files in WPA mode and the file with the list of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
279 LTRANS units. */
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
281 static void
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 lto_wpa_write_files (void)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
284 unsigned i, n_sets;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
285 ltrans_partition part;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
286 FILE *ltrans_output_list_stream;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
287 char *temp_filename;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
288 auto_vec <char *>temp_filenames;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
289 auto_vec <int>temp_priority;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
290 size_t blen;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
291
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
292 /* Open the LTRANS output list. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
293 if (!ltrans_output_list)
111
kono
parents: 67
diff changeset
294 fatal_error (input_location, "no LTRANS output list filename provided");
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
295
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 timevar_push (TV_WHOPR_WPA);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297
111
kono
parents: 67
diff changeset
298 FOR_EACH_VEC_ELT (ltrans_partitions, i, part)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
299 lto_stats.num_output_symtab_nodes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
300 += lto_symtab_encoder_size (part->encoder);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 timevar_pop (TV_WHOPR_WPA);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 timevar_push (TV_WHOPR_WPA_IO);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
306 cgraph_node *node;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
307 /* Do body modifications needed for streaming before we fork out
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308 worker processes. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
309 FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 if (!node->clone_of && gimple_has_body_p (node->decl))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
311 lto_prepare_function_for_streaming (node);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313 ggc_trim ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
314 report_heap_memory_use ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
315
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
316 /* Generate a prefix for the LTRANS unit files. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
317 blen = strlen (ltrans_output_list);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
318 temp_filename = (char *) xmalloc (blen + sizeof ("2147483648.o"));
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
319 strcpy (temp_filename, ltrans_output_list);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
320 if (blen > sizeof (".out")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
321 && strcmp (temp_filename + blen - sizeof (".out") + 1,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
322 ".out") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
323 temp_filename[blen - sizeof (".out") + 1] = '\0';
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
324 blen = strlen (temp_filename);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325
111
kono
parents: 67
diff changeset
326 n_sets = ltrans_partitions.length ();
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327 unsigned sets_per_worker = n_sets;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
328 if (lto_parallelism > 1)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
329 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 if (lto_parallelism > (int)n_sets)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331 lto_parallelism = n_sets;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 sets_per_worker = (n_sets + lto_parallelism - 1) / lto_parallelism;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 }
111
kono
parents: 67
diff changeset
334
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 for (i = 0; i < n_sets; i++)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 {
111
kono
parents: 67
diff changeset
337 ltrans_partition part = ltrans_partitions[i];
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
338
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
339 /* Write all the nodes in SET. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
340 sprintf (temp_filename + blen, "%u.o", i);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
341
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
342 if (!quiet_flag)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 fprintf (stderr, " %s (%s %i insns)", temp_filename, part->name,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 part->insns);
111
kono
parents: 67
diff changeset
345 if (symtab->dump_file)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
346 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
347 lto_symtab_encoder_iterator lsei;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
348
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
349 fprintf (symtab->dump_file,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
350 "Writing partition %s to file %s, %i insns\n",
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
351 part->name, temp_filename, part->insns);
111
kono
parents: 67
diff changeset
352 fprintf (symtab->dump_file, " Symbols in partition: ");
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
353 for (lsei = lsei_start_in_partition (part->encoder);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
354 !lsei_end_p (lsei);
111
kono
parents: 67
diff changeset
355 lsei_next_in_partition (&lsei))
kono
parents: 67
diff changeset
356 {
kono
parents: 67
diff changeset
357 symtab_node *node = lsei_node (lsei);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 fprintf (symtab->dump_file, "%s ", node->dump_asm_name ());
111
kono
parents: 67
diff changeset
359 }
kono
parents: 67
diff changeset
360 fprintf (symtab->dump_file, "\n Symbols in boundary: ");
kono
parents: 67
diff changeset
361 for (lsei = lsei_start (part->encoder); !lsei_end_p (lsei);
kono
parents: 67
diff changeset
362 lsei_next (&lsei))
kono
parents: 67
diff changeset
363 {
kono
parents: 67
diff changeset
364 symtab_node *node = lsei_node (lsei);
kono
parents: 67
diff changeset
365 if (!lto_symtab_encoder_in_partition_p (part->encoder, node))
kono
parents: 67
diff changeset
366 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
367 fprintf (symtab->dump_file, "%s ", node->dump_asm_name ());
111
kono
parents: 67
diff changeset
368 cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
kono
parents: 67
diff changeset
369 if (cnode
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
370 && lto_symtab_encoder_encode_body_p (part->encoder,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
371 cnode))
111
kono
parents: 67
diff changeset
372 fprintf (symtab->dump_file, "(body included)");
kono
parents: 67
diff changeset
373 else
kono
parents: 67
diff changeset
374 {
kono
parents: 67
diff changeset
375 varpool_node *vnode = dyn_cast <varpool_node *> (node);
kono
parents: 67
diff changeset
376 if (vnode
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
377 && lto_symtab_encoder_encode_initializer_p (part->encoder,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
378 vnode))
111
kono
parents: 67
diff changeset
379 fprintf (symtab->dump_file, "(initializer included)");
kono
parents: 67
diff changeset
380 }
kono
parents: 67
diff changeset
381 }
kono
parents: 67
diff changeset
382 }
kono
parents: 67
diff changeset
383 fprintf (symtab->dump_file, "\n");
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
384 }
111
kono
parents: 67
diff changeset
385 gcc_checking_assert (lto_symtab_encoder_size (part->encoder) || !i);
kono
parents: 67
diff changeset
386
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
387 temp_priority.safe_push (part->insns);
111
kono
parents: 67
diff changeset
388 temp_filenames.safe_push (xstrdup (temp_filename));
kono
parents: 67
diff changeset
389 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
390 memory_block_pool::trim (0);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
391
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
392 for (int set = 0; set < MAX (lto_parallelism, 1); set++)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
393 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
394 stream_out_partitions (temp_filename, blen, set * sets_per_worker,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
395 MIN ((set + 1) * sets_per_worker, n_sets),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
396 set == MAX (lto_parallelism, 1) - 1);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
397 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
398
111
kono
parents: 67
diff changeset
399 ltrans_output_list_stream = fopen (ltrans_output_list, "w");
kono
parents: 67
diff changeset
400 if (ltrans_output_list_stream == NULL)
kono
parents: 67
diff changeset
401 fatal_error (input_location,
kono
parents: 67
diff changeset
402 "opening LTRANS output list %s: %m", ltrans_output_list);
kono
parents: 67
diff changeset
403 for (i = 0; i < n_sets; i++)
kono
parents: 67
diff changeset
404 {
kono
parents: 67
diff changeset
405 unsigned int len = strlen (temp_filenames[i]);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
406 if (fprintf (ltrans_output_list_stream, "%i\n", temp_priority[i]) < 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
407 || fwrite (temp_filenames[i], 1, len, ltrans_output_list_stream) < len
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
408 || fwrite ("\n", 1, 1, ltrans_output_list_stream) < 1)
111
kono
parents: 67
diff changeset
409 fatal_error (input_location, "writing to LTRANS output list %s: %m",
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
410 ltrans_output_list);
111
kono
parents: 67
diff changeset
411 free (temp_filenames[i]);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
413
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 lto_stats.num_output_files += n_sets;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
416 /* Close the LTRANS output list. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
417 if (fclose (ltrans_output_list_stream))
111
kono
parents: 67
diff changeset
418 fatal_error (input_location,
kono
parents: 67
diff changeset
419 "closing LTRANS output list %s: %m", ltrans_output_list);
kono
parents: 67
diff changeset
420
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
421 free_ltrans_partitions ();
111
kono
parents: 67
diff changeset
422 free (temp_filename);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 timevar_pop (TV_WHOPR_WPA_IO);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 /* Perform whole program analysis (WPA) on the callgraph and write out the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 optimization plan. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
429
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 static void
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 do_whole_program_analysis (void)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 {
111
kono
parents: 67
diff changeset
433 symtab_node *node;
kono
parents: 67
diff changeset
434
kono
parents: 67
diff changeset
435 lto_parallelism = 1;
kono
parents: 67
diff changeset
436
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
437 /* TODO: jobserver communication is not supported, yet. */
111
kono
parents: 67
diff changeset
438 if (!strcmp (flag_wpa, "jobserver"))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
439 lto_parallelism = param_max_lto_streaming_parallelism;
111
kono
parents: 67
diff changeset
440 else
kono
parents: 67
diff changeset
441 {
kono
parents: 67
diff changeset
442 lto_parallelism = atoi (flag_wpa);
kono
parents: 67
diff changeset
443 if (lto_parallelism <= 0)
kono
parents: 67
diff changeset
444 lto_parallelism = 0;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
445 if (lto_parallelism >= param_max_lto_streaming_parallelism)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
446 lto_parallelism = param_max_lto_streaming_parallelism;
111
kono
parents: 67
diff changeset
447 }
kono
parents: 67
diff changeset
448
kono
parents: 67
diff changeset
449 timevar_start (TV_PHASE_OPT_GEN);
kono
parents: 67
diff changeset
450
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
451 /* Note that since we are in WPA mode, materialize_cgraph will not
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
452 actually read in all the function bodies. It only materializes
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 the decls and cgraph nodes so that analysis can be performed. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 materialize_cgraph ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 /* Reading in the cgraph uses different timers, start timing WPA now. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 timevar_push (TV_WHOPR_WPA);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
458
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
459 if (pre_ipa_mem_report)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
460 dump_memory_report ("Memory consumption before IPA");
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
461
111
kono
parents: 67
diff changeset
462 symtab->function_flags_ready = true;
kono
parents: 67
diff changeset
463
kono
parents: 67
diff changeset
464 if (symtab->dump_file)
kono
parents: 67
diff changeset
465 symtab->dump (symtab->dump_file);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 bitmap_obstack_initialize (NULL);
111
kono
parents: 67
diff changeset
467 symtab->state = IPA_SSA;
kono
parents: 67
diff changeset
468
kono
parents: 67
diff changeset
469 execute_ipa_pass_list (g->get_passes ()->all_regular_ipa_passes);
kono
parents: 67
diff changeset
470
kono
parents: 67
diff changeset
471 /* When WPA analysis raises errors, do not bother to output anything. */
kono
parents: 67
diff changeset
472 if (seen_error ())
kono
parents: 67
diff changeset
473 return;
kono
parents: 67
diff changeset
474
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 /* We are about to launch the final LTRANS phase, stop the WPA timer. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 timevar_pop (TV_WHOPR_WPA);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
477
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
478 /* We are no longer going to stream in anything. Free some memory. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
479 lto_free_file_name_hash ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
480
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
481
111
kono
parents: 67
diff changeset
482 timevar_push (TV_WHOPR_PARTITIONING);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
483
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
484 gcc_assert (!dump_file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
485 dump_file = dump_begin (partition_dump_id, NULL);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
486
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
487 if (dump_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
488 symtab->dump (dump_file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
489
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
490 symtab_node::checking_verify_symtab_nodes ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
491 bitmap_obstack_release (NULL);
111
kono
parents: 67
diff changeset
492 if (flag_lto_partition == LTO_PARTITION_1TO1)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
493 lto_1_to_1_map ();
111
kono
parents: 67
diff changeset
494 else if (flag_lto_partition == LTO_PARTITION_MAX)
kono
parents: 67
diff changeset
495 lto_max_map ();
kono
parents: 67
diff changeset
496 else if (flag_lto_partition == LTO_PARTITION_ONE)
kono
parents: 67
diff changeset
497 lto_balanced_map (1, INT_MAX);
kono
parents: 67
diff changeset
498 else if (flag_lto_partition == LTO_PARTITION_BALANCED)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
499 lto_balanced_map (param_lto_partitions,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
500 param_max_partition_size);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
501 else
111
kono
parents: 67
diff changeset
502 gcc_unreachable ();
kono
parents: 67
diff changeset
503
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
504 /* Size summaries are needed for balanced partitioning. Free them now so
111
kono
parents: 67
diff changeset
505 the memory can be used for streamer caches. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
506 ipa_free_size_summary ();
111
kono
parents: 67
diff changeset
507
kono
parents: 67
diff changeset
508 /* AUX pointers are used by partitioning code to bookkeep number of
kono
parents: 67
diff changeset
509 partitions symbol is in. This is no longer needed. */
kono
parents: 67
diff changeset
510 FOR_EACH_SYMBOL (node)
kono
parents: 67
diff changeset
511 node->aux = NULL;
kono
parents: 67
diff changeset
512
kono
parents: 67
diff changeset
513 lto_stats.num_cgraph_partitions += ltrans_partitions.length ();
kono
parents: 67
diff changeset
514
kono
parents: 67
diff changeset
515 /* Find out statics that need to be promoted
kono
parents: 67
diff changeset
516 to globals with hidden visibility because they are accessed from multiple
kono
parents: 67
diff changeset
517 partitions. */
kono
parents: 67
diff changeset
518 lto_promote_cross_file_statics ();
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
519 if (dump_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
520 dump_end (partition_dump_id, dump_file);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
521 dump_file = NULL;
111
kono
parents: 67
diff changeset
522 timevar_pop (TV_WHOPR_PARTITIONING);
kono
parents: 67
diff changeset
523
kono
parents: 67
diff changeset
524 timevar_stop (TV_PHASE_OPT_GEN);
kono
parents: 67
diff changeset
525
kono
parents: 67
diff changeset
526 /* Collect a last time - in lto_wpa_write_files we may end up forking
kono
parents: 67
diff changeset
527 with the idea that this doesn't increase memory usage. So we
kono
parents: 67
diff changeset
528 absoultely do not want to collect after that. */
kono
parents: 67
diff changeset
529 ggc_collect ();
kono
parents: 67
diff changeset
530
kono
parents: 67
diff changeset
531 timevar_start (TV_PHASE_STREAM_OUT);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
532 if (!quiet_flag)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
533 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
534 fprintf (stderr, "\nStreaming out");
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
535 fflush (stderr);
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
536 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
537 lto_wpa_write_files ();
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
538 if (!quiet_flag)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
539 fprintf (stderr, "\n");
111
kono
parents: 67
diff changeset
540 timevar_stop (TV_PHASE_STREAM_OUT);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
541
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
542 if (post_ipa_mem_report)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
543 dump_memory_report ("Memory consumption after IPA");
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
544
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 /* Show the LTO report before launching LTRANS. */
111
kono
parents: 67
diff changeset
546 if (flag_lto_report || (flag_wpa && flag_lto_report_wpa))
kono
parents: 67
diff changeset
547 print_lto_report_1 ();
kono
parents: 67
diff changeset
548 if (mem_report_wpa)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
549 dump_memory_report ("Final");
111
kono
parents: 67
diff changeset
550 }
kono
parents: 67
diff changeset
551
kono
parents: 67
diff changeset
552 /* Create artificial pointers for "omp declare target link" vars. */
kono
parents: 67
diff changeset
553
kono
parents: 67
diff changeset
554 static void
kono
parents: 67
diff changeset
555 offload_handle_link_vars (void)
kono
parents: 67
diff changeset
556 {
kono
parents: 67
diff changeset
557 #ifdef ACCEL_COMPILER
kono
parents: 67
diff changeset
558 varpool_node *var;
kono
parents: 67
diff changeset
559 FOR_EACH_VARIABLE (var)
kono
parents: 67
diff changeset
560 if (lookup_attribute ("omp declare target link",
kono
parents: 67
diff changeset
561 DECL_ATTRIBUTES (var->decl)))
kono
parents: 67
diff changeset
562 {
kono
parents: 67
diff changeset
563 tree type = build_pointer_type (TREE_TYPE (var->decl));
kono
parents: 67
diff changeset
564 tree link_ptr_var = make_node (VAR_DECL);
kono
parents: 67
diff changeset
565 TREE_TYPE (link_ptr_var) = type;
kono
parents: 67
diff changeset
566 TREE_USED (link_ptr_var) = 1;
kono
parents: 67
diff changeset
567 TREE_STATIC (link_ptr_var) = 1;
kono
parents: 67
diff changeset
568 SET_DECL_MODE (link_ptr_var, TYPE_MODE (type));
kono
parents: 67
diff changeset
569 DECL_SIZE (link_ptr_var) = TYPE_SIZE (type);
kono
parents: 67
diff changeset
570 DECL_SIZE_UNIT (link_ptr_var) = TYPE_SIZE_UNIT (type);
kono
parents: 67
diff changeset
571 DECL_ARTIFICIAL (link_ptr_var) = 1;
kono
parents: 67
diff changeset
572 tree var_name = DECL_ASSEMBLER_NAME (var->decl);
kono
parents: 67
diff changeset
573 char *new_name
kono
parents: 67
diff changeset
574 = ACONCAT ((IDENTIFIER_POINTER (var_name), "_linkptr", NULL));
kono
parents: 67
diff changeset
575 DECL_NAME (link_ptr_var) = get_identifier (new_name);
kono
parents: 67
diff changeset
576 SET_DECL_ASSEMBLER_NAME (link_ptr_var, DECL_NAME (link_ptr_var));
kono
parents: 67
diff changeset
577 SET_DECL_VALUE_EXPR (var->decl, build_simple_mem_ref (link_ptr_var));
kono
parents: 67
diff changeset
578 DECL_HAS_VALUE_EXPR_P (var->decl) = 1;
kono
parents: 67
diff changeset
579 }
kono
parents: 67
diff changeset
580 #endif
kono
parents: 67
diff changeset
581 }
kono
parents: 67
diff changeset
582
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
583 unsigned int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
584 lto_option_lang_mask (void)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
585 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
586 return CL_LTO;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
587 }
111
kono
parents: 67
diff changeset
588
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 /* Main entry point for the GIMPLE front end. This front end has
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 three main personalities:
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
591
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 - LTO (-flto). All the object files on the command line are
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 loaded in memory and processed as a single translation unit.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 This is the traditional link-time optimization behavior.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 - WPA (-fwpa). Only the callgraph and summary information for
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 files in the command file are loaded. A single callgraph
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 (without function bodies) is instantiated for the whole set of
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 files. IPA passes are only allowed to analyze the call graph
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 and make transformation decisions. The callgraph is
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 partitioned, each partition is written to a new object file
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
602 together with the transformation decisions.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
603
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 - LTRANS (-fltrans). Similar to -flto but it prevents the IPA
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 summary files from running again. Since WPA computed summary
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 information and decided what transformations to apply, LTRANS
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 simply applies them. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 void
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
610 lto_main (void)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 {
111
kono
parents: 67
diff changeset
612 /* LTO is called as a front end, even though it is not a front end.
kono
parents: 67
diff changeset
613 Because it is called as a front end, TV_PHASE_PARSING and
kono
parents: 67
diff changeset
614 TV_PARSE_GLOBAL are active, and we need to turn them off while
kono
parents: 67
diff changeset
615 doing LTO. Later we turn them back on so they are active up in
kono
parents: 67
diff changeset
616 toplev.c. */
kono
parents: 67
diff changeset
617 timevar_pop (TV_PARSE_GLOBAL);
kono
parents: 67
diff changeset
618 timevar_stop (TV_PHASE_PARSING);
kono
parents: 67
diff changeset
619
kono
parents: 67
diff changeset
620 timevar_start (TV_PHASE_SETUP);
kono
parents: 67
diff changeset
621
kono
parents: 67
diff changeset
622 /* Initialize the LTO front end. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
623 lto_fe_init ();
111
kono
parents: 67
diff changeset
624
kono
parents: 67
diff changeset
625 timevar_stop (TV_PHASE_SETUP);
kono
parents: 67
diff changeset
626 timevar_start (TV_PHASE_STREAM_IN);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
627
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 /* Read all the symbols and call graph from all the files in the
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 command line. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 read_cgraph_and_symbols (num_in_fnames, in_fnames);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
631
111
kono
parents: 67
diff changeset
632 timevar_stop (TV_PHASE_STREAM_IN);
kono
parents: 67
diff changeset
633
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
634 if (!seen_error ())
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 {
111
kono
parents: 67
diff changeset
636 offload_handle_link_vars ();
kono
parents: 67
diff changeset
637
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 /* If WPA is enabled analyze the whole call graph and create an
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 optimization plan. Otherwise, read in all the function
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 bodies and continue with optimization. */
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
641 if (flag_wpa)
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 do_whole_program_analysis ();
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 {
111
kono
parents: 67
diff changeset
645 timevar_start (TV_PHASE_OPT_GEN);
kono
parents: 67
diff changeset
646
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 materialize_cgraph ();
111
kono
parents: 67
diff changeset
648 if (!flag_ltrans)
kono
parents: 67
diff changeset
649 lto_promote_statics_nonwpa ();
kono
parents: 67
diff changeset
650
kono
parents: 67
diff changeset
651 /* Annotate the CU DIE and mark the early debug phase as finished. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
652 debuginfo_early_start ();
111
kono
parents: 67
diff changeset
653 debug_hooks->early_finish ("<artificial>");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
654 debuginfo_early_stop ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 /* Let the middle end know that we have read and merged all of
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
657 the input files. */
111
kono
parents: 67
diff changeset
658 symtab->compile ();
kono
parents: 67
diff changeset
659
kono
parents: 67
diff changeset
660 timevar_stop (TV_PHASE_OPT_GEN);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 /* FIXME lto, if the processes spawned by WPA fail, we miss
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 the chance to print WPA's report, so WPA will call
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 print_lto_report before launching LTRANS. If LTRANS was
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 launched directly by the driver we would not need to do
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 this. */
111
kono
parents: 67
diff changeset
667 if (flag_lto_report || (flag_wpa && flag_lto_report_wpa))
kono
parents: 67
diff changeset
668 print_lto_report_1 ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 }
111
kono
parents: 67
diff changeset
671
kono
parents: 67
diff changeset
672 /* Here we make LTO pretend to be a parser. */
kono
parents: 67
diff changeset
673 timevar_start (TV_PHASE_PARSING);
kono
parents: 67
diff changeset
674 timevar_push (TV_PARSE_GLOBAL);
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 }