comparison gcc/doc/passes.texi @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 @c markers: BUG TODO 1 @c markers: BUG TODO
2 2
3 @c Copyright (C) 1988-2018 Free Software Foundation, Inc. 3 @c Copyright (C) 1988-2020 Free Software Foundation, Inc.
4 @c This is part of the GCC manual. 4 @c This is part of the GCC manual.
5 @c For copying conditions, see the file gcc.texi. 5 @c For copying conditions, see the file gcc.texi.
6 6
7 @node Passes 7 @node Passes
8 @chapter Passes and Files of the Compiler 8 @chapter Passes and Files of the Compiler
18 18
19 @menu 19 @menu
20 * Parsing pass:: The language front end turns text into bits. 20 * Parsing pass:: The language front end turns text into bits.
21 * Gimplification pass:: The bits are turned into something we can optimize. 21 * Gimplification pass:: The bits are turned into something we can optimize.
22 * Pass manager:: Sequencing the optimization passes. 22 * Pass manager:: Sequencing the optimization passes.
23 * IPA passes:: Inter-procedural optimizations.
23 * Tree SSA passes:: Optimizations on a high-level representation. 24 * Tree SSA passes:: Optimizations on a high-level representation.
24 * RTL passes:: Optimizations on a low-level representation. 25 * RTL passes:: Optimizations on a low-level representation.
25 * Optimization info:: Dumping optimization information from passes. 26 * Optimization info:: Dumping optimization information from passes.
26 @end menu 27 @end menu
27 28
176 177
177 TODO: describe the global variables set up by the pass manager, 178 TODO: describe the global variables set up by the pass manager,
178 and a brief description of how a new pass should use it. 179 and a brief description of how a new pass should use it.
179 I need to look at what info RTL passes use first@enddots{} 180 I need to look at what info RTL passes use first@enddots{}
180 181
182 @node IPA passes
183 @section Inter-procedural optimization passes
184 @cindex IPA passes
185 @cindex inter-procedural optimization passes
186
187 The inter-procedural optimization (IPA) passes use call graph
188 information to perform transformations across function boundaries.
189 IPA is a critical part of link-time optimization (LTO) and
190 whole-program (WHOPR) optimization, and these passes are structured
191 with the needs of LTO and WHOPR in mind by dividing their operations
192 into stages. For detailed discussion of the LTO/WHOPR IPA pass stages
193 and interfaces, see @ref{IPA}.
194
195 The following briefly describes the inter-procedural optimization (IPA)
196 passes, which are split into small IPA passes, regular IPA passes,
197 and late IPA passes, according to the LTO/WHOPR processing model.
198
199 @menu
200 * Small IPA passes::
201 * Regular IPA passes::
202 * Late IPA passes::
203 @end menu
204
205 @node Small IPA passes
206 @subsection Small IPA passes
207 @cindex small IPA passes
208 A small IPA pass is a pass derived from @code{simple_ipa_opt_pass}.
209 As described in @ref{IPA}, it does everything at once and
210 defines only the @emph{Execute} stage. During this
211 stage it accesses and modifies the function bodies.
212 No @code{generate_summary}, @code{read_summary}, or @code{write_summary}
213 hooks are defined.
214
215 @itemize @bullet
216 @item IPA free lang data
217
218 This pass frees resources that are used by the front end but are
219 not needed once it is done. It is located in @file{tree.c} and is described by
220 @code{pass_ipa_free_lang_data}.
221
222 @item IPA function and variable visibility
223
224 This is a local function pass handling visibilities of all symbols. This
225 happens before LTO streaming, so @option{-fwhole-program} should be ignored
226 at this level. It is located in @file{ipa-visibility.c} and is described by
227 @code{pass_ipa_function_and_variable_visibility}.
228
229 @item IPA remove symbols
230
231 This pass performs reachability analysis and reclaims all unreachable nodes.
232 It is located in @file{passes.c} and is described by
233 @code{pass_ipa_remove_symbols}.
234
235 @item IPA OpenACC
236
237 This is a pass group for OpenACC processing. It is located in
238 @file{tree-ssa-loop.c} and is described by @code{pass_ipa_oacc}.
239
240 @item IPA points-to analysis
241
242 This is a tree-based points-to analysis pass. The idea behind this analyzer
243 is to generate set constraints from the program, then solve the resulting
244 constraints in order to generate the points-to sets. It is located in
245 @file{tree-ssa-structalias.c} and is described by @code{pass_ipa_pta}.
246
247 @item IPA OpenACC kernels
248
249 This is a pass group for processing OpenACC kernels regions. It is a
250 subpass of the IPA OpenACC pass group that runs on offloaded functions
251 containing OpenACC kernels loops. It is located in
252 @file{tree-ssa-loop.c} and is described by
253 @code{pass_ipa_oacc_kernels}.
254
255 @item Target clone
256
257 This is a pass for parsing functions with multiple target attributes.
258 It is located in @file{multiple_target.c} and is described by
259 @code{pass_target_clone}.
260
261 @item IPA auto profile
262
263 This pass uses AutoFDO profiling data to annotate the control flow graph.
264 It is located in @file{auto-profile.c} and is described by
265 @code{pass_ipa_auto_profile}.
266
267 @item IPA tree profile
268
269 This pass does profiling for all functions in the call graph.
270 It calculates branch
271 probabilities and basic block execution counts. It is located
272 in @file{tree-profile.c} and is described by @code{pass_ipa_tree_profile}.
273
274 @item IPA free function summary
275
276 This pass is a small IPA pass when argument @code{small_p} is true.
277 It releases inline function summaries and call summaries.
278 It is located in @file{ipa-fnsummary.c} and is described by
279 @code{pass_ipa_free_free_fn_summary}.
280
281 @item IPA increase alignment
282
283 This pass increases the alignment of global arrays to improve
284 vectorization. It is located in @file{tree-vectorizer.c}
285 and is described by @code{pass_ipa_increase_alignment}.
286
287 @item IPA transactional memory
288
289 This pass is for transactional memory support.
290 It is located in @file{trans-mem.c} and is described by
291 @code{pass_ipa_tm}.
292
293 @item IPA lower emulated TLS
294
295 This pass lowers thread-local storage (TLS) operations
296 to emulation functions provided by libgcc.
297 It is located in @file{tree-emutls.c} and is described by
298 @code{pass_ipa_lower_emutls}.
299
300 @end itemize
301
302 @node Regular IPA passes
303 @subsection Regular IPA passes
304 @cindex regular IPA passes
305
306 A regular IPA pass is a pass derived from @code{ipa_opt_pass_d} that
307 is executed in WHOPR compilation. Regular IPA passes may have summary
308 hooks implemented in any of the LGEN, WPA or LTRANS stages (@pxref{IPA}).
309
310 @itemize @bullet
311 @item IPA whole program visibility
312
313 This pass performs various optimizations involving symbol visibility
314 with @option{-fwhole-program}, including symbol privatization,
315 discovering local functions, and dismantling comdat groups. It is
316 located in @file{ipa-visibility.c} and is described by
317 @code{pass_ipa_whole_program_visibility}.
318
319 @item IPA profile
320
321 The IPA profile pass propagates profiling frequencies across the call
322 graph. It is located in @file{ipa-profile.c} and is described by
323 @code{pass_ipa_profile}.
324
325 @item IPA identical code folding
326
327 This is the inter-procedural identical code folding pass.
328 The goal of this transformation is to discover functions
329 and read-only variables that have exactly the same semantics. It is
330 located in @file{ipa-icf.c} and is described by @code{pass_ipa_icf}.
331
332 @item IPA devirtualization
333
334 This pass performs speculative devirtualization based on the type
335 inheritance graph. When a polymorphic call has only one likely target
336 in the unit, it is turned into a speculative call. It is located in
337 @file{ipa-devirt.c} and is described by @code{pass_ipa_devirt}.
338
339 @item IPA constant propagation
340
341 The goal of this pass is to discover functions that are always invoked
342 with some arguments with the same known constant values and to modify
343 the functions accordingly. It can also do partial specialization and
344 type-based devirtualization. It is located in @file{ipa-cp.c} and is
345 described by @code{pass_ipa_cp}.
346
347 @item IPA scalar replacement of aggregates
348
349 This pass can replace an aggregate parameter with a set of other parameters
350 representing part of the original, turning those passed by reference
351 into new ones which pass the value directly. It also removes unused
352 function return values and unused function parameters. This pass is
353 located in @file{ipa-sra.c} and is described by @code{pass_ipa_sra}.
354
355 @item IPA constructor/destructor merge
356
357 This pass merges multiple constructors and destructors for static
358 objects into single functions. It's only run at LTO time unless the
359 target doesn't support constructors and destructors natively. The
360 pass is located in @file{ipa.c} and is described by
361 @code{pass_ipa_cdtor_merge}.
362
363 @item IPA HSA
364
365 This pass is part of the GCC support for HSA (Heterogeneous System
366 Architecture) accelerators. It is responsible for creation of HSA
367 clones and emitting HSAIL instructions for them. It is located in
368 @file{ipa-hsa.c} and is described by @code{pass_ipa_hsa}.
369
370 @item IPA function summary
371
372 This pass provides function analysis for inter-procedural passes.
373 It collects estimates of function body size, execution time, and frame
374 size for each function. It also estimates information about function
375 calls: call statement size, time and how often the parameters change
376 for each call. It is located in @file{ipa-fnsummary.c} and is
377 described by @code{pass_ipa_fn_summary}.
378
379 @item IPA inline
380
381 The IPA inline pass handles function inlining with whole-program
382 knowledge. Small functions that are candidates for inlining are
383 ordered in increasing badness, bounded by unit growth parameters.
384 Unreachable functions are removed from the call graph. Functions called
385 once and not exported from the unit are inlined. This pass is located in
386 @file{ipa-inline.c} and is described by @code{pass_ipa_inline}.
387
388 @item IPA pure/const analysis
389
390 This pass marks functions as being either const (@code{TREE_READONLY}) or
391 pure (@code{DECL_PURE_P}). The per-function information is produced
392 by @code{pure_const_generate_summary}, then the global information is computed
393 by performing a transitive closure over the call graph. It is located in
394 @file{ipa-pure-const.c} and is described by @code{pass_ipa_pure_const}.
395
396 @item IPA free function summary
397
398 This pass is a regular IPA pass when argument @code{small_p} is false.
399 It releases inline function summaries and call summaries.
400 It is located in @file{ipa-fnsummary.c} and is described by
401 @code{pass_ipa_free_fn_summary}.
402
403 @item IPA reference
404
405 This pass gathers information about how variables whose scope is
406 confined to the compilation unit are used. It is located in
407 @file{ipa-reference.c} and is described by @code{pass_ipa_reference}.
408
409 @item IPA single use
410
411 This pass checks whether variables are used by a single function.
412 It is located in @file{ipa.c} and is described by
413 @code{pass_ipa_single_use}.
414
415 @item IPA comdats
416
417 This pass looks for static symbols that are used exclusively
418 within one comdat group, and moves them into that comdat group. It is
419 located in @file{ipa-comdats.c} and is described by
420 @code{pass_ipa_comdats}.
421
422 @end itemize
423
424 @node Late IPA passes
425 @subsection Late IPA passes
426 @cindex late IPA passes
427
428 Late IPA passes are simple IPA passes executed after
429 the regular passes. In WHOPR mode the passes are executed after
430 partitioning and thus see just parts of the compiled unit.
431
432 @itemize @bullet
433 @item Materialize all clones
434
435 Once all functions from compilation unit are in memory, produce all clones
436 and update all calls. It is located in @file{ipa.c} and is described by
437 @code{pass_materialize_all_clones}.
438
439 @item IPA points-to analysis
440
441 Points-to analysis; this is the same as the points-to-analysis pass
442 run with the small IPA passes (@pxref{Small IPA passes}).
443
444 @item OpenMP simd clone
445
446 This is the OpenMP constructs' SIMD clone pass. It creates the appropriate
447 SIMD clones for functions tagged as elemental SIMD functions.
448 It is located in @file{omp-simd-clone.c} and is described by
449 @code{pass_omp_simd_clone}.
450
451 @end itemize
452
181 @node Tree SSA passes 453 @node Tree SSA passes
182 @section Tree SSA passes 454 @section Tree SSA passes
183 455
184 The following briefly describes the Tree optimization passes that are 456 The following briefly describes the Tree optimization passes that are
185 run after gimplification and what source files they are located in. 457 run after gimplification and what source files they are located in.