annotate gcc/doc/passes.texi @ 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
111
kono
parents: 67
diff changeset
1 @c markers: BUG TODO
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 @c Copyright (C) 1988-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 @c This is part of the GCC manual.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 @c For copying conditions, see the file gcc.texi.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 @node Passes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 @chapter Passes and Files of the Compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 @cindex passes and files of the compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 @cindex files and passes of the compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 @cindex compiler passes and files
111
kono
parents: 67
diff changeset
12 @cindex pass dumps
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 This chapter is dedicated to giving an overview of the optimization and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 code generation passes of the compiler. In the process, it describes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 some of the language front end interface, though this description is no
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 where near complete.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 @menu
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 * Parsing pass:: The language front end turns text into bits.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 * Gimplification pass:: The bits are turned into something we can optimize.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 * Pass manager:: Sequencing the optimization passes.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
23 * IPA passes:: Inter-procedural optimizations.
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
24 * Tree SSA passes:: Optimizations on a high-level representation.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 * RTL passes:: Optimizations on a low-level representation.
111
kono
parents: 67
diff changeset
26 * Optimization info:: Dumping optimization information from passes.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 @end menu
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 @node Parsing pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 @section Parsing pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 @cindex GENERIC
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 @findex lang_hooks.parse_file
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 The language front end is invoked only once, via
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 @code{lang_hooks.parse_file}, to parse the entire input. The language
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 front end may use any intermediate language representation deemed
111
kono
parents: 67
diff changeset
36 appropriate. The C front end uses GENERIC trees (@pxref{GENERIC}), plus
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 a double handful of language specific tree codes defined in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 @file{c-common.def}. The Fortran front end uses a completely different
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 private representation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 @cindex GIMPLE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 @cindex gimplification
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 @cindex gimplifier
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 @cindex language-independent intermediate representation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 @cindex intermediate representation lowering
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 @cindex lowering, language-dependent intermediate representation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 At some point the front end must translate the representation used in the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 front end to a representation understood by the language-independent
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 portions of the compiler. Current practice takes one of two forms.
111
kono
parents: 67
diff changeset
50 The C front end manually invokes the gimplifier (@pxref{GIMPLE}) on each function,
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 and uses the gimplifier callbacks to convert the language-specific tree
111
kono
parents: 67
diff changeset
52 nodes directly to GIMPLE before passing the function off to be compiled.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 The Fortran front end converts from a private representation to GENERIC,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 which is later lowered to GIMPLE when the function is compiled. Which
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 route to choose probably depends on how well GENERIC (plus extensions)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 can be made to match up with the source language and necessary parsing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 data structures.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 BUG: Gimplification must occur before nested function lowering,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 and nested function lowering must be done by the front end before
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 passing the data off to cgraph.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 TODO: Cgraph should control nested function lowering. It would
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 only be invoked when it is certain that the outer-most function
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 is used.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 TODO: Cgraph needs a gimplify_function callback. It should be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 invoked when (1) it is certain that the function is used, (2)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 warning flags specified by the user require some amount of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 compilation in order to honor, (3) the language indicates that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 semantic analysis is not complete until gimplification occurs.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 Hum@dots{} this sounds overly complicated. Perhaps we should just
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 have the front end gimplify always; in most cases it's only one
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 function call.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 The front end needs to pass all function definitions and top level
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 declarations off to the middle-end so that they can be compiled and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 emitted to the object file. For a simple procedural language, it is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 usually most convenient to do this as each top level declaration or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 definition is seen. There is also a distinction to be made between
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 generating functional code and generating complete debug information.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 The only thing that is absolutely required for functional code is that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 function and data @emph{definitions} be passed to the middle-end. For
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 complete debug information, function, data and type declarations
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 should all be passed as well.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 @findex rest_of_decl_compilation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 @findex rest_of_type_compilation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 @findex cgraph_finalize_function
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 In any case, the front end needs each complete top-level function or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 data declaration, and each data definition should be passed to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 @code{rest_of_decl_compilation}. Each complete type definition should
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 be passed to @code{rest_of_type_compilation}. Each function definition
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 should be passed to @code{cgraph_finalize_function}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 TODO: I know rest_of_compilation currently has all sorts of
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
97 RTL generation semantics. I plan to move all code generation
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
98 bits (both Tree and RTL) to compile_function. Should we hide
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 cgraph from the front ends and move back to rest_of_compilation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 as the official interface? Possibly we should rename all three
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 interfaces such that the names match in some meaningful way and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 that is more descriptive than "rest_of".
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 The middle-end will, at its option, emit the function and data
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 definitions immediately or queue them for later processing.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 @node Gimplification pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 @section Gimplification pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 @cindex gimplification
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 @cindex GIMPLE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 @dfn{Gimplification} is a whimsical term for the process of converting
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 the intermediate representation of a function into the GIMPLE language
111
kono
parents: 67
diff changeset
114 (@pxref{GIMPLE}). The term stuck, and so words like ``gimplification'',
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 ``gimplify'', ``gimplifier'' and the like are sprinkled throughout this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 section of code.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 While a front end may certainly choose to generate GIMPLE directly if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 it chooses, this can be a moderately complex process unless the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 intermediate language used by the front end is already fairly simple.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 Usually it is easier to generate GENERIC trees plus extensions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 and let the language-independent gimplifier do most of the work.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 @findex gimplify_function_tree
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 @findex gimplify_expr
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 @findex lang_hooks.gimplify_expr
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 The main entry point to this pass is @code{gimplify_function_tree}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 located in @file{gimplify.c}. From here we process the entire
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 function gimplifying each statement in turn. The main workhorse
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 for this pass is @code{gimplify_expr}. Approximately everything
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 passes through here at least once, and it is from here that we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 invoke the @code{lang_hooks.gimplify_expr} callback.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 The callback should examine the expression in question and return
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 @code{GS_UNHANDLED} if the expression is not a language specific
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 construct that requires attention. Otherwise it should alter the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 expression in some way to such that forward progress is made toward
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 producing valid GIMPLE@. If the callback is certain that the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 transformation is complete and the expression is valid GIMPLE, it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 should return @code{GS_ALL_DONE}. Otherwise it should return
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 @code{GS_OK}, which will cause the expression to be processed again.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 If the callback encounters an error during the transformation (because
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 the front end is relying on the gimplification process to finish
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 semantic checks), it should return @code{GS_ERROR}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 @node Pass manager
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 @section Pass manager
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 The pass manager is located in @file{passes.c}, @file{tree-optimize.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 and @file{tree-pass.h}.
111
kono
parents: 67
diff changeset
151 It processes passes as described in @file{passes.def}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 Its job is to run all of the individual passes in the correct order,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 and take care of standard bookkeeping that applies to every pass.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 The theory of operation is that each pass defines a structure that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 represents everything we need to know about that pass---when it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 should be run, how it should be run, what intermediate language
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 form or on-the-side data structures it needs. We register the pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 to be run in some particular order, and the pass manager arranges
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 for everything to happen in the correct order.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 The actuality doesn't completely live up to the theory at present.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 Command-line switches and @code{timevar_id_t} enumerations must still
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 be defined elsewhere. The pass manager validates constraints but does
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 not attempt to (re-)generate data structures or lower intermediate
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 language form based on the requirements of the next pass. Nevertheless,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 what is present is useful, and a far sight better than nothing at all.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
169 Each pass should have a unique name.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 Each pass may have its own dump file (for GCC debugging purposes).
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
171 Passes with a name starting with a star do not dump anything.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
172 Sometimes passes are supposed to share a dump file / option name.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
173 To still give these unique names, you can use a prefix that is delimited
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
174 by a space from the part that is used for the dump file / option name.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
175 E.g. When the pass name is "ud dce", the name used for dump file/options
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
176 is "dce".
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 TODO: describe the global variables set up by the pass manager,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 and a brief description of how a new pass should use it.
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
180 I need to look at what info RTL passes use first@enddots{}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
182 @node IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
183 @section Inter-procedural optimization passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
184 @cindex IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
185 @cindex inter-procedural optimization passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
186
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
187 The inter-procedural optimization (IPA) passes use call graph
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
188 information to perform transformations across function boundaries.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
189 IPA is a critical part of link-time optimization (LTO) and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
190 whole-program (WHOPR) optimization, and these passes are structured
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
191 with the needs of LTO and WHOPR in mind by dividing their operations
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
192 into stages. For detailed discussion of the LTO/WHOPR IPA pass stages
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
193 and interfaces, see @ref{IPA}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
194
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
195 The following briefly describes the inter-procedural optimization (IPA)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
196 passes, which are split into small IPA passes, regular IPA passes,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
197 and late IPA passes, according to the LTO/WHOPR processing model.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
198
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
199 @menu
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
200 * Small IPA passes::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
201 * Regular IPA passes::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
202 * Late IPA passes::
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
203 @end menu
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
204
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
205 @node Small IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
206 @subsection Small IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
207 @cindex small IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
208 A small IPA pass is a pass derived from @code{simple_ipa_opt_pass}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
209 As described in @ref{IPA}, it does everything at once and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
210 defines only the @emph{Execute} stage. During this
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
211 stage it accesses and modifies the function bodies.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
212 No @code{generate_summary}, @code{read_summary}, or @code{write_summary}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
213 hooks are defined.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
214
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
215 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
216 @item IPA free lang data
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
217
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
218 This pass frees resources that are used by the front end but are
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
219 not needed once it is done. It is located in @file{tree.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
220 @code{pass_ipa_free_lang_data}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
221
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
222 @item IPA function and variable visibility
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
223
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
224 This is a local function pass handling visibilities of all symbols. This
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
225 happens before LTO streaming, so @option{-fwhole-program} should be ignored
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
226 at this level. It is located in @file{ipa-visibility.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
227 @code{pass_ipa_function_and_variable_visibility}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
228
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
229 @item IPA remove symbols
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
230
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
231 This pass performs reachability analysis and reclaims all unreachable nodes.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
232 It is located in @file{passes.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
233 @code{pass_ipa_remove_symbols}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
234
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
235 @item IPA OpenACC
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
236
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
237 This is a pass group for OpenACC processing. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
238 @file{tree-ssa-loop.c} and is described by @code{pass_ipa_oacc}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
239
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 @item IPA points-to analysis
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
241
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
242 This is a tree-based points-to analysis pass. The idea behind this analyzer
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
243 is to generate set constraints from the program, then solve the resulting
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
244 constraints in order to generate the points-to sets. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
245 @file{tree-ssa-structalias.c} and is described by @code{pass_ipa_pta}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
246
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 @item IPA OpenACC kernels
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
248
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
249 This is a pass group for processing OpenACC kernels regions. It is a
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
250 subpass of the IPA OpenACC pass group that runs on offloaded functions
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
251 containing OpenACC kernels loops. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
252 @file{tree-ssa-loop.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
253 @code{pass_ipa_oacc_kernels}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
254
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
255 @item Target clone
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
256
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
257 This is a pass for parsing functions with multiple target attributes.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
258 It is located in @file{multiple_target.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
259 @code{pass_target_clone}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
260
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
261 @item IPA auto profile
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
262
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
263 This pass uses AutoFDO profiling data to annotate the control flow graph.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
264 It is located in @file{auto-profile.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
265 @code{pass_ipa_auto_profile}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
266
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
267 @item IPA tree profile
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
269 This pass does profiling for all functions in the call graph.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
270 It calculates branch
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
271 probabilities and basic block execution counts. It is located
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
272 in @file{tree-profile.c} and is described by @code{pass_ipa_tree_profile}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
273
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
274 @item IPA free function summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
275
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
276 This pass is a small IPA pass when argument @code{small_p} is true.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
277 It releases inline function summaries and call summaries.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
278 It is located in @file{ipa-fnsummary.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
279 @code{pass_ipa_free_free_fn_summary}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
280
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
281 @item IPA increase alignment
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
283 This pass increases the alignment of global arrays to improve
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
284 vectorization. It is located in @file{tree-vectorizer.c}
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
285 and is described by @code{pass_ipa_increase_alignment}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
286
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
287 @item IPA transactional memory
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
288
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
289 This pass is for transactional memory support.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
290 It is located in @file{trans-mem.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
291 @code{pass_ipa_tm}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
292
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
293 @item IPA lower emulated TLS
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
294
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
295 This pass lowers thread-local storage (TLS) operations
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
296 to emulation functions provided by libgcc.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
297 It is located in @file{tree-emutls.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
298 @code{pass_ipa_lower_emutls}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
299
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
300 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
301
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
302 @node Regular IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
303 @subsection Regular IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
304 @cindex regular IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
305
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
306 A regular IPA pass is a pass derived from @code{ipa_opt_pass_d} that
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
307 is executed in WHOPR compilation. Regular IPA passes may have summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308 hooks implemented in any of the LGEN, WPA or LTRANS stages (@pxref{IPA}).
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
309
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
311 @item IPA whole program visibility
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313 This pass performs various optimizations involving symbol visibility
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
314 with @option{-fwhole-program}, including symbol privatization,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
315 discovering local functions, and dismantling comdat groups. It is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
316 located in @file{ipa-visibility.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
317 @code{pass_ipa_whole_program_visibility}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
318
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
319 @item IPA profile
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
320
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
321 The IPA profile pass propagates profiling frequencies across the call
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
322 graph. It is located in @file{ipa-profile.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
323 @code{pass_ipa_profile}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
324
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
325 @item IPA identical code folding
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
326
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
327 This is the inter-procedural identical code folding pass.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
328 The goal of this transformation is to discover functions
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
329 and read-only variables that have exactly the same semantics. It is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 located in @file{ipa-icf.c} and is described by @code{pass_ipa_icf}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 @item IPA devirtualization
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334 This pass performs speculative devirtualization based on the type
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 inheritance graph. When a polymorphic call has only one likely target
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 in the unit, it is turned into a speculative call. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 @file{ipa-devirt.c} and is described by @code{pass_ipa_devirt}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
339 @item IPA constant propagation
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
340
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
341 The goal of this pass is to discover functions that are always invoked
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 with some arguments with the same known constant values and to modify
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 the functions accordingly. It can also do partial specialization and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 type-based devirtualization. It is located in @file{ipa-cp.c} and is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
345 described by @code{pass_ipa_cp}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
346
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
347 @item IPA scalar replacement of aggregates
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
348
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
349 This pass can replace an aggregate parameter with a set of other parameters
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
350 representing part of the original, turning those passed by reference
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
351 into new ones which pass the value directly. It also removes unused
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
352 function return values and unused function parameters. This pass is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
353 located in @file{ipa-sra.c} and is described by @code{pass_ipa_sra}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
354
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
355 @item IPA constructor/destructor merge
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
356
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
357 This pass merges multiple constructors and destructors for static
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 objects into single functions. It's only run at LTO time unless the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
359 target doesn't support constructors and destructors natively. The
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
360 pass is located in @file{ipa.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
361 @code{pass_ipa_cdtor_merge}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
362
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
363 @item IPA HSA
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
364
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
365 This pass is part of the GCC support for HSA (Heterogeneous System
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
366 Architecture) accelerators. It is responsible for creation of HSA
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
367 clones and emitting HSAIL instructions for them. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
368 @file{ipa-hsa.c} and is described by @code{pass_ipa_hsa}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
369
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
370 @item IPA function summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
371
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
372 This pass provides function analysis for inter-procedural passes.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
373 It collects estimates of function body size, execution time, and frame
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
374 size for each function. It also estimates information about function
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
375 calls: call statement size, time and how often the parameters change
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
376 for each call. It is located in @file{ipa-fnsummary.c} and is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
377 described by @code{pass_ipa_fn_summary}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
378
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
379 @item IPA inline
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
380
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
381 The IPA inline pass handles function inlining with whole-program
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
382 knowledge. Small functions that are candidates for inlining are
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
383 ordered in increasing badness, bounded by unit growth parameters.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
384 Unreachable functions are removed from the call graph. Functions called
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
385 once and not exported from the unit are inlined. This pass is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
386 @file{ipa-inline.c} and is described by @code{pass_ipa_inline}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
387
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
388 @item IPA pure/const analysis
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
389
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
390 This pass marks functions as being either const (@code{TREE_READONLY}) or
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
391 pure (@code{DECL_PURE_P}). The per-function information is produced
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
392 by @code{pure_const_generate_summary}, then the global information is computed
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
393 by performing a transitive closure over the call graph. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
394 @file{ipa-pure-const.c} and is described by @code{pass_ipa_pure_const}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
395
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
396 @item IPA free function summary
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
397
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
398 This pass is a regular IPA pass when argument @code{small_p} is false.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
399 It releases inline function summaries and call summaries.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
400 It is located in @file{ipa-fnsummary.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
401 @code{pass_ipa_free_fn_summary}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
402
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
403 @item IPA reference
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
404
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
405 This pass gathers information about how variables whose scope is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
406 confined to the compilation unit are used. It is located in
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
407 @file{ipa-reference.c} and is described by @code{pass_ipa_reference}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
408
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
409 @item IPA single use
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
410
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
411 This pass checks whether variables are used by a single function.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
412 It is located in @file{ipa.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
413 @code{pass_ipa_single_use}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
414
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
415 @item IPA comdats
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
416
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
417 This pass looks for static symbols that are used exclusively
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
418 within one comdat group, and moves them into that comdat group. It is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
419 located in @file{ipa-comdats.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
420 @code{pass_ipa_comdats}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
421
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
422 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
423
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
424 @node Late IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
425 @subsection Late IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
426 @cindex late IPA passes
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
427
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
428 Late IPA passes are simple IPA passes executed after
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
429 the regular passes. In WHOPR mode the passes are executed after
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
430 partitioning and thus see just parts of the compiled unit.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
431
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
432 @itemize @bullet
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
433 @item Materialize all clones
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
434
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
435 Once all functions from compilation unit are in memory, produce all clones
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
436 and update all calls. It is located in @file{ipa.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
437 @code{pass_materialize_all_clones}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
438
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
439 @item IPA points-to analysis
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
440
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
441 Points-to analysis; this is the same as the points-to-analysis pass
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
442 run with the small IPA passes (@pxref{Small IPA passes}).
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
443
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
444 @item OpenMP simd clone
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
445
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
446 This is the OpenMP constructs' SIMD clone pass. It creates the appropriate
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
447 SIMD clones for functions tagged as elemental SIMD functions.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
448 It is located in @file{omp-simd-clone.c} and is described by
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
449 @code{pass_omp_simd_clone}.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
450
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
451 @end itemize
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
452
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
453 @node Tree SSA passes
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
454 @section Tree SSA passes
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
456 The following briefly describes the Tree optimization passes that are
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 run after gimplification and what source files they are located in.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 @itemize @bullet
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 @item Remove useless statements
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 This pass is an extremely simple sweep across the gimple code in which
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 we identify obviously dead code and remove it. Here we do things like
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 simplify @code{if} statements with constant conditions, remove
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465 exception handling constructs surrounding code that obviously cannot
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 throw, remove lexical bindings that contain no variables, and other
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 assorted simplistic cleanups. The idea is to get rid of the obvious
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 stuff quickly rather than wait until later when it's more work to get
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 rid of it. This pass is located in @file{tree-cfg.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 @code{pass_remove_useless_stmts}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 @item OpenMP lowering
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 If OpenMP generation (@option{-fopenmp}) is enabled, this pass lowers
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 OpenMP constructs into GIMPLE.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 Lowering of OpenMP constructs involves creating replacement
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 expressions for local variables that have been mapped using data
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 sharing clauses, exposing the control flow of most synchronization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 directives and adding region markers to facilitate the creation of the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 control flow graph. The pass is located in @file{omp-low.c} and is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 described by @code{pass_lower_omp}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 @item OpenMP expansion
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 If OpenMP generation (@option{-fopenmp}) is enabled, this pass expands
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 parallel regions into their own functions to be invoked by the thread
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 library. The pass is located in @file{omp-low.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 @code{pass_expand_omp}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 @item Lower control flow
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 This pass flattens @code{if} statements (@code{COND_EXPR})
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 and moves lexical bindings (@code{BIND_EXPR}) out of line. After
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 this pass, all @code{if} statements will have exactly two @code{goto}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 statements in its @code{then} and @code{else} arms. Lexical binding
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 information for each statement will be found in @code{TREE_BLOCK} rather
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 than being inferred from its position under a @code{BIND_EXPR}. This
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 pass is found in @file{gimple-low.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 @code{pass_lower_cf}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 @item Lower exception handling control flow
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 This pass decomposes high-level exception handling constructs
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 (@code{TRY_FINALLY_EXPR} and @code{TRY_CATCH_EXPR}) into a form
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 that explicitly represents the control flow involved. After this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 pass, @code{lookup_stmt_eh_region} will return a non-negative
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 number for any statement that may have EH control flow semantics;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 examine @code{tree_can_throw_internal} or @code{tree_can_throw_external}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 for exact semantics. Exact control flow may be extracted from
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 @code{foreach_reachable_handler}. The EH region nesting tree is defined
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 in @file{except.h} and built in @file{except.c}. The lowering pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 itself is in @file{tree-eh.c} and is described by @code{pass_lower_eh}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 @item Build the control flow graph
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 This pass decomposes a function into basic blocks and creates all of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 the edges that connect them. It is located in @file{tree-cfg.c} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 is described by @code{pass_build_cfg}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 @item Find all referenced variables
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 This pass walks the entire function and collects an array of all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 variables referenced in the function, @code{referenced_vars}. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 index at which a variable is found in the array is used as a UID
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 for the variable within this function. This data is needed by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 SSA rewriting routines. The pass is located in @file{tree-dfa.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 and is described by @code{pass_referenced_vars}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 @item Enter static single assignment form
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 This pass rewrites the function such that it is in SSA form. After
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 this pass, all @code{is_gimple_reg} variables will be referenced by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 @code{SSA_NAME}, and all occurrences of other variables will be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 annotated with @code{VDEFS} and @code{VUSES}; PHI nodes will have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 been inserted as necessary for each basic block. This pass is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 located in @file{tree-ssa.c} and is described by @code{pass_build_ssa}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 @item Warn for uninitialized variables
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 This pass scans the function for uses of @code{SSA_NAME}s that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 are fed by default definition. For non-parameter variables, such
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 uses are uninitialized. The pass is run twice, before and after
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 optimization (if turned on). In the first pass we only warn for uses that are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 positively uninitialized; in the second pass we warn for uses that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 are possibly uninitialized. The pass is located in @file{tree-ssa.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 and is defined by @code{pass_early_warn_uninitialized} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 @code{pass_late_warn_uninitialized}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 @item Dead code elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 This pass scans the function for statements without side effects whose
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 result is unused. It does not do memory life analysis, so any value
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 that is stored in memory is considered used. The pass is run multiple
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 times throughout the optimization process. It is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 @file{tree-ssa-dce.c} and is described by @code{pass_dce}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 @item Dominator optimizations
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 This pass performs trivial dominator-based copy and constant propagation,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 expression simplification, and jump threading. It is run multiple times
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
562 throughout the optimization process. It is located in @file{tree-ssa-dom.c}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 and is described by @code{pass_dominator}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 @item Forward propagation of single-use variables
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 This pass attempts to remove redundant computation by substituting
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 variables that are used once into the expression that uses them and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 seeing if the result can be simplified. It is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 @file{tree-ssa-forwprop.c} and is described by @code{pass_forwprop}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 @item Copy Renaming
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 This pass attempts to change the name of compiler temporaries involved in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 copy operations such that SSA->normal can coalesce the copy away. When compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 temporaries are copies of user variables, it also renames the compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 temporary to the user variable resulting in better use of user symbols. It is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 located in @file{tree-ssa-copyrename.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 @code{pass_copyrename}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 @item PHI node optimizations
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 This pass recognizes forms of PHI inputs that can be represented as
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584 conditional expressions and rewrites them into straight line code.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 It is located in @file{tree-ssa-phiopt.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586 @code{pass_phiopt}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 @item May-alias optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 This pass performs a flow sensitive SSA-based points-to analysis.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 The resulting may-alias, must-alias, and escape analysis information
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 is used to promote variables from in-memory addressable objects to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 non-aliased variables that can be renamed into SSA form. We also
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 update the @code{VDEF}/@code{VUSE} memory tags for non-renameable
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 aggregates so that we get fewer false kills. The pass is located
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 in @file{tree-ssa-alias.c} and is described by @code{pass_may_alias}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 Interprocedural points-to information is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 @file{tree-ssa-structalias.c} and described by @code{pass_ipa_pta}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 @item Profiling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602
111
kono
parents: 67
diff changeset
603 This pass instruments the function in order to collect runtime block
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 and value profiling data. Such data may be fed back into the compiler
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605 on a subsequent run so as to allow optimization based on expected
111
kono
parents: 67
diff changeset
606 execution frequencies. The pass is located in @file{tree-profile.c} and
kono
parents: 67
diff changeset
607 is described by @code{pass_ipa_tree_profile}.
kono
parents: 67
diff changeset
608
kono
parents: 67
diff changeset
609 @item Static profile estimation
kono
parents: 67
diff changeset
610
kono
parents: 67
diff changeset
611 This pass implements series of heuristics to guess propababilities
kono
parents: 67
diff changeset
612 of branches. The resulting predictions are turned into edge profile
kono
parents: 67
diff changeset
613 by propagating branches across the control flow graphs.
kono
parents: 67
diff changeset
614 The pass is located in @file{tree-profile.c} and is described by
kono
parents: 67
diff changeset
615 @code{pass_profile}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 @item Lower complex arithmetic
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 This pass rewrites complex arithmetic operations into their component
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 scalar arithmetic operations. The pass is located in @file{tree-complex.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 and is described by @code{pass_lower_complex}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 @item Scalar replacement of aggregates
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 This pass rewrites suitable non-aliased local aggregate variables into
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626 a set of scalar variables. The resulting scalar variables are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 rewritten into SSA form, which allows subsequent optimization passes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
628 to do a significantly better job with them. The pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629 @file{tree-sra.c} and is described by @code{pass_sra}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631 @item Dead store elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 This pass eliminates stores to memory that are subsequently overwritten
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 by another store, without any intervening loads. The pass is located
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 in @file{tree-ssa-dse.c} and is described by @code{pass_dse}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
636
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 @item Tail recursion elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 This pass transforms tail recursion into a loop. It is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 @file{tree-tailcall.c} and is described by @code{pass_tail_recursion}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
641
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
642 @item Forward store motion
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 This pass sinks stores and assignments down the flowgraph closer to their
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 use point. The pass is located in @file{tree-ssa-sink.c} and is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646 described by @code{pass_sink_code}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 @item Partial redundancy elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 This pass eliminates partially redundant computations, as well as
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 performing load motion. The pass is located in @file{tree-ssa-pre.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 and is described by @code{pass_pre}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
653
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 Just before partial redundancy elimination, if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 @option{-funsafe-math-optimizations} is on, GCC tries to convert
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
656 divisions to multiplications by the reciprocal. The pass is located
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
657 in @file{tree-ssa-math-opts.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
658 @code{pass_cse_reciprocal}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
659
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
660 @item Full redundancy elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
661
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 This is a simpler form of PRE that only eliminates redundancies that
111
kono
parents: 67
diff changeset
663 occur on all paths. It is located in @file{tree-ssa-pre.c} and
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
664 described by @code{pass_fre}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
665
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
666 @item Loop optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
667
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
668 The main driver of the pass is placed in @file{tree-ssa-loop.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 and described by @code{pass_loop}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
670
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
671 The optimizations performed by this pass are:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 Loop invariant motion. This pass moves only invariants that
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
674 would be hard to handle on RTL level (function calls, operations that expand to
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 operands of conditions that are invariant out of the loop, so that we can use
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 just trivial invariantness analysis in loop unswitching. The pass also includes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 store motion. The pass is implemented in @file{tree-ssa-loop-im.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 Canonical induction variable creation. This pass creates a simple counter
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 for number of iterations of the loop and replaces the exit condition of the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 loop using it, in case when a complicated analysis is necessary to determine
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 the number of iterations. Later optimizations then may determine the number
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 easily. The pass is implemented in @file{tree-ssa-loop-ivcanon.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 Induction variable optimizations. This pass performs standard induction
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 variable optimizations, including strength reduction, induction variable
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 merging and induction variable elimination. The pass is implemented in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 @file{tree-ssa-loop-ivopts.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 Loop unswitching. This pass moves the conditional jumps that are invariant
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 out of the loops. To achieve this, a duplicate of the loop is created for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
693 each possible outcome of conditional jump(s). The pass is implemented in
111
kono
parents: 67
diff changeset
694 @file{tree-ssa-loop-unswitch.c}.
kono
parents: 67
diff changeset
695
kono
parents: 67
diff changeset
696 Loop splitting. If a loop contains a conditional statement that is
kono
parents: 67
diff changeset
697 always true for one part of the iteration space and false for the other
kono
parents: 67
diff changeset
698 this pass splits the loop into two, one dealing with one side the other
kono
parents: 67
diff changeset
699 only with the other, thereby removing one inner-loop conditional. The
kono
parents: 67
diff changeset
700 pass is implemented in @file{tree-ssa-loop-split.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 The optimizations also use various utility functions contained in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 @file{tree-ssa-loop-manip.c}, @file{cfgloop.c}, @file{cfgloopanal.c} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 @file{cfgloopmanip.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 Vectorization. This pass transforms loops to operate on vector types
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 instead of scalar types. Data parallelism across loop iterations is exploited
111
kono
parents: 67
diff changeset
708 to group data elements from consecutive iterations into a vector and operate
kono
parents: 67
diff changeset
709 on them in parallel. Depending on available target support the loop is
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 conceptually unrolled by a factor @code{VF} (vectorization factor), which is
111
kono
parents: 67
diff changeset
711 the number of elements operated upon in parallel in each iteration, and the
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 @code{VF} copies of each scalar operation are fused to form a vector operation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 Additional loop transformations such as peeling and versioning may take place
111
kono
parents: 67
diff changeset
714 to align the number of iterations, and to align the memory accesses in the
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
715 loop.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
716 The pass is implemented in @file{tree-vectorizer.c} (the main driver),
111
kono
parents: 67
diff changeset
717 @file{tree-vect-loop.c} and @file{tree-vect-loop-manip.c} (loop specific parts
kono
parents: 67
diff changeset
718 and general loop utilities), @file{tree-vect-slp} (loop-aware SLP
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
719 functionality), @file{tree-vect-stmts.c} and @file{tree-vect-data-refs.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 Analysis of data references is in @file{tree-data-ref.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
722 SLP Vectorization. This pass performs vectorization of straight-line code. The
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
723 pass is implemented in @file{tree-vectorizer.c} (the main driver),
111
kono
parents: 67
diff changeset
724 @file{tree-vect-slp.c}, @file{tree-vect-stmts.c} and
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
725 @file{tree-vect-data-refs.c}.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
726
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 Autoparallelization. This pass splits the loop iteration space to run
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 into several threads. The pass is implemented in @file{tree-parloops.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
730 Graphite is a loop transformation framework based on the polyhedral
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
731 model. Graphite stands for Gimple Represented as Polyhedra. The
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
732 internals of this infrastructure are documented in
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
733 @w{@uref{http://gcc.gnu.org/wiki/Graphite}}. The passes working on
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
734 this representation are implemented in the various @file{graphite-*}
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
735 files.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 19
diff changeset
736
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 @item Tree level if-conversion for vectorizer
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 This pass applies if-conversion to simple loops to help vectorizer.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 We identify if convertible loops, if-convert statements and merge
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 basic blocks in one big block. The idea is to present loop in such
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 form so that vectorizer can have one to one mapping between statements
111
kono
parents: 67
diff changeset
743 and available vector operations. This pass is located in
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
744 @file{tree-if-conv.c} and is described by @code{pass_if_conversion}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 @item Conditional constant propagation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 This pass relaxes a lattice of values in order to identify those
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 that must be constant even in the presence of conditional branches.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 The pass is located in @file{tree-ssa-ccp.c} and is described
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 by @code{pass_ccp}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 A related pass that works on memory loads and stores, and not just
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 register values, is located in @file{tree-ssa-ccp.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 @code{pass_store_ccp}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 @item Conditional copy propagation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 This is similar to constant propagation but the lattice of values is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 the ``copy-of'' relation. It eliminates redundant copies from the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 code. The pass is located in @file{tree-ssa-copy.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 @code{pass_copy_prop}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 A related pass that works on memory copies, and not just register
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 copies, is located in @file{tree-ssa-copy.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 @code{pass_store_copy_prop}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 @item Value range propagation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 This transformation is similar to constant propagation but
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 instead of propagating single constant values, it propagates
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 known value ranges. The implementation is based on Patterson's
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 range propagation algorithm (Accurate Static Branch Prediction by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 Value Range Propagation, J. R. C. Patterson, PLDI '95). In
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 contrast to Patterson's algorithm, this implementation does not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 propagate branch probabilities nor it uses more than a single
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 range per SSA name. This means that the current implementation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 cannot be used for branch prediction (though adapting it would
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 not be difficult). The pass is located in @file{tree-vrp.c} and is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 described by @code{pass_vrp}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
781
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 @item Folding built-in functions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784 This pass simplifies built-in functions, as applicable, with constant
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
785 arguments or with inferable string lengths. It is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
786 @file{tree-ssa-ccp.c} and is described by @code{pass_fold_builtins}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
787
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
788 @item Split critical edges
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
789
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
790 This pass identifies critical edges and inserts empty basic blocks
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
791 such that the edge is no longer critical. The pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
792 @file{tree-cfg.c} and is described by @code{pass_split_crit_edges}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
793
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
794 @item Control dependence dead code elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
795
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
796 This pass is a stronger form of dead code elimination that can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
797 eliminate unnecessary control flow statements. It is located
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
798 in @file{tree-ssa-dce.c} and is described by @code{pass_cd_dce}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
799
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
800 @item Tail call elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
802 This pass identifies function calls that may be rewritten into
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
803 jumps. No code transformation is actually applied here, but the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
804 data and control flow problem is solved. The code transformation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
805 requires target support, and so is delayed until RTL@. In the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
806 meantime @code{CALL_EXPR_TAILCALL} is set indicating the possibility.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
807 The pass is located in @file{tree-tailcall.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
808 @code{pass_tail_calls}. The RTL transformation is handled by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
809 @code{fixup_tail_calls} in @file{calls.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
810
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
811 @item Warn for function return without value
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
812
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
813 For non-void functions, this pass locates return statements that do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
814 not specify a value and issues a warning. Such a statement may have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
815 been injected by falling off the end of the function. This pass is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
816 run last so that we have as much time as possible to prove that the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
817 statement is not reachable. It is located in @file{tree-cfg.c} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 is described by @code{pass_warn_function_return}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 @item Leave static single assignment form
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 This pass rewrites the function such that it is in normal form. At
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 the same time, we eliminate as many single-use temporaries as possible,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 so the intermediate language is no longer GIMPLE, but GENERIC@. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 pass is located in @file{tree-outof-ssa.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 @code{pass_del_ssa}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 @item Merge PHI nodes that feed into one another
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 This is part of the CFG cleanup passes. It attempts to join PHI nodes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 from a forwarder CFG block into another block with PHI nodes. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832 pass is located in @file{tree-cfgcleanup.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833 @code{pass_merge_phi}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
834
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
835 @item Return value optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
836
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
837 If a function always returns the same local variable, and that local
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
838 variable is an aggregate type, then the variable is replaced with the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839 return value for the function (i.e., the function's DECL_RESULT). This
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840 is equivalent to the C++ named return value optimization applied to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
841 GIMPLE@. The pass is located in @file{tree-nrv.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842 @code{pass_nrv}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
844 @item Return slot optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
845
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
846 If a function returns a memory object and is called as @code{var =
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
847 foo()}, this pass tries to change the call so that the address of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
848 @code{var} is sent to the caller to avoid an extra memory copy. This
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 pass is located in @code{tree-nrv.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 @code{pass_return_slot}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 @item Optimize calls to @code{__builtin_object_size}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 This is a propagation pass similar to CCP that tries to remove calls
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 to @code{__builtin_object_size} when the size of the object can be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 computed at compile-time. This pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 @file{tree-object-size.c} and is described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 @code{pass_object_sizes}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 @item Loop invariant motion
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 This pass removes expensive loop-invariant computations out of loops.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 The pass is located in @file{tree-ssa-loop.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 @code{pass_lim}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 @item Loop nest optimizations
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 This is a family of loop transformations that works on loop nests. It
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 includes loop interchange, scaling, skewing and reversal and they are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 all geared to the optimization of data locality in array traversals
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 and the removal of dependencies that hamper optimizations such as loop
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 parallelization and vectorization. The pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 @file{tree-loop-linear.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 @code{pass_linear_transform}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 @item Removal of empty loops
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 This pass removes loops with no code in them. The pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 @file{tree-ssa-loop-ivcanon.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 @code{pass_empty_loop}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 @item Unrolling of small loops
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 This pass completely unrolls loops with few iterations. The pass
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 is located in @file{tree-ssa-loop-ivcanon.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 @code{pass_complete_unroll}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 @item Predictive commoning
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 This pass makes the code reuse the computations from the previous
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 iterations of the loops, especially loads and stores to memory.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 It does so by storing the values of these computations to a bank
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 of temporary variables that are rotated at the end of loop. To avoid
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 the need for this rotation, the loop is then unrolled and the copies
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 of the loop body are rewritten to use the appropriate version of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 the temporary variable. This pass is located in @file{tree-predcom.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 and described by @code{pass_predcom}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 @item Array prefetching
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
900
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 This pass issues prefetch instructions for array references inside
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 loops. The pass is located in @file{tree-ssa-loop-prefetch.c} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 described by @code{pass_loop_prefetch}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
904
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 @item Reassociation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 This pass rewrites arithmetic expressions to enable optimizations that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 operate on them, like redundancy elimination and vectorization. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 pass is located in @file{tree-ssa-reassoc.c} and described by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 @code{pass_reassoc}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
911
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 @item Optimization of @code{stdarg} functions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 This pass tries to avoid the saving of register arguments into the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 stack on entry to @code{stdarg} functions. If the function doesn't
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 use any @code{va_start} macros, no registers need to be saved. If
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 @code{va_start} macros are used, the @code{va_list} variables don't
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 escape the function, it is only necessary to save registers that will
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 be used in @code{va_arg} macros. For instance, if @code{va_arg} is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 only used with integral types in the function, floating point
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
921 registers don't need to be saved. This pass is located in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 @code{tree-stdarg.c} and described by @code{pass_stdarg}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 @end itemize
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
925
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
926 @node RTL passes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 @section RTL passes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
928
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
929 The following briefly describes the RTL generation and optimization
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
930 passes that are run after the Tree optimization passes.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
931
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 @itemize @bullet
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 @item RTL generation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
934
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 @c Avoiding overfull is tricky here.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 The source files for RTL generation include
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 @file{stmt.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
938 @file{calls.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
939 @file{expr.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 @file{explow.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 @file{expmed.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 @file{function.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 @file{optabs.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 and @file{emit-rtl.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
945 Also, the file
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
946 @file{insn-emit.c}, generated from the machine description by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 program @code{genemit}, is used in this pass. The header file
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 @file{expr.h} is used for communication within this pass.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
949
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 @findex genflags
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 @findex gencodes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 The header files @file{insn-flags.h} and @file{insn-codes.h},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 generated from the machine description by the programs @code{genflags}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
954 and @code{gencodes}, tell this pass which standard names are available
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 for use and which patterns correspond to them.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
956
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
957 @item Generation of exception landing pads
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 This pass generates the glue that handles communication between the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 exception handling library routines and the exception handlers within
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 the function. Entry points in the function that are invoked by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 exception handling library are called @dfn{landing pads}. The code
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
963 for this pass is located in @file{except.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
965 @item Control flow graph cleanup
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 This pass removes unreachable code, simplifies jumps to next, jumps to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 jump, jumps across jumps, etc. The pass is run multiple times.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 For historical reasons, it is occasionally referred to as the ``jump
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 optimization pass''. The bulk of the code for this pass is in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 @file{cfgcleanup.c}, and there are support routines in @file{cfgrtl.c}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 and @file{jump.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 @item Forward propagation of single-def values
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 This pass attempts to remove redundant computation by substituting
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 variables that come from a single definition, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 seeing if the result can be simplified. It performs copy propagation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 and addressing mode selection. The pass is run twice, with values
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
980 being propagated into loops only on the second run. The code is
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
981 located in @file{fwprop.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 @item Common subexpression elimination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 This pass removes redundant computation within basic blocks, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 optimizes addressing modes based on cost. The pass is run twice.
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
987 The code for this pass is located in @file{cse.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
989 @item Global common subexpression elimination
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 This pass performs two
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 different types of GCSE depending on whether you are optimizing for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 size or not (LCM based GCSE tends to increase code size for a gain in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 speed, while Morel-Renvoise based GCSE does not).
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 When optimizing for size, GCSE is done using Morel-Renvoise Partial
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 Redundancy Elimination, with the exception that it does not try to move
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 invariants out of loops---that is left to the loop optimization pass.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 If MR PRE GCSE is done, code hoisting (aka unification) is also done, as
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 well as load motion.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 If you are optimizing for speed, LCM (lazy code motion) based GCSE is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 done. LCM is based on the work of Knoop, Ruthing, and Steffen. LCM
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 based GCSE also does loop invariant code motion. We also perform load
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 and store motion when optimizing for speed.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 Regardless of which type of GCSE is used, the GCSE pass also performs
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 global constant and copy propagation.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 The source file for this pass is @file{gcse.c}, and the LCM routines
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 are in @file{lcm.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009 @item Loop optimization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 This pass performs several loop related optimizations.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012 The source files @file{cfgloopanal.c} and @file{cfgloopmanip.c} contain
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 generic loop analysis and manipulation code. Initialization and finalization
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 of loop structures is handled by @file{loop-init.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 A loop invariant motion pass is implemented in @file{loop-invariant.c}.
111
kono
parents: 67
diff changeset
1016 Basic block level optimizations---unrolling, and peeling loops---
kono
parents: 67
diff changeset
1017 are implemented in @file{loop-unroll.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 Replacing of the exit condition of loops by special machine-dependent
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 instructions is handled by @file{loop-doloop.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 @item Jump bypassing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 This pass is an aggressive form of GCSE that transforms the control
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 flow graph of a function by propagating constants into conditional
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 branch instructions. The source file for this pass is @file{gcse.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1027 @item If conversion
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 This pass attempts to replace conditional branches and surrounding
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 assignments with arithmetic, boolean value producing comparison
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 instructions, and conditional move instructions. In the very last
111
kono
parents: 67
diff changeset
1032 invocation after reload/LRA, it will generate predicated instructions
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1033 when supported by the target. The code is located in @file{ifcvt.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 @item Web construction
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 This pass splits independent uses of each pseudo-register. This can
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 improve effect of the other transformation, such as CSE or register
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1039 allocation. The code for this pass is located in @file{web.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 @item Instruction combination
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 This pass attempts to combine groups of two or three instructions that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 are related by data flow into single instructions. It combines the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 RTL expressions for the instructions by substitution, simplifies the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 result using algebra, and then attempts to match the result against
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1047 the machine description. The code is located in @file{combine.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1049 @item Mode switching optimization
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 This pass looks for instructions that require the processor to be in a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 specific ``mode'' and minimizes the number of mode changes required to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 satisfy all users. What these modes are, and what they apply to are
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1054 completely target-specific. The code for this pass is located in
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1055 @file{mode-switching.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 @cindex modulo scheduling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 @cindex sms, swing, software pipelining
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 @item Modulo scheduling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 This pass looks at innermost loops and reorders their instructions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 by overlapping different iterations. Modulo scheduling is performed
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1063 immediately before instruction scheduling. The code for this pass is
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1064 located in @file{modulo-sched.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 @item Instruction scheduling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 This pass looks for instructions whose output will not be available by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 the time that it is used in subsequent instructions. Memory loads and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 floating point instructions often have this behavior on RISC machines.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 It re-orders instructions within a basic block to try to separate the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 definition and use of items that otherwise would cause pipeline
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 stalls. This pass is performed twice, before and after register
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1074 allocation. The code for this pass is located in @file{haifa-sched.c},
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1075 @file{sched-deps.c}, @file{sched-ebb.c}, @file{sched-rgn.c} and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 @file{sched-vis.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 @item Register allocation
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 These passes make sure that all occurrences of pseudo registers are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 eliminated, either by allocating them to a hard register, replacing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 them by an equivalent expression (e.g.@: a constant) or by placing
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 them on the stack. This is done in several subpasses:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 @itemize @bullet
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087 The integrated register allocator (@acronym{IRA}). It is called
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 integrated because coalescing, register live range splitting, and hard
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 register preferencing are done on-the-fly during coloring. It also
111
kono
parents: 67
diff changeset
1090 has better integration with the reload/LRA pass. Pseudo-registers spilled
kono
parents: 67
diff changeset
1091 by the allocator or the reload/LRA have still a chance to get
kono
parents: 67
diff changeset
1092 hard-registers if the reload/LRA evicts some pseudo-registers from
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 hard-registers. The allocator helps to choose better pseudos for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 spilling based on their live ranges and to coalesce stack slots
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 allocated for the spilled pseudo-registers. IRA is a regional
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 register allocator which is transformed into Chaitin-Briggs allocator
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 if there is one region. By default, IRA chooses regions using
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 register pressure but the user can force it to use one region or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 regions corresponding to all loops.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1101 Source files of the allocator are @file{ira.c}, @file{ira-build.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 @file{ira-costs.c}, @file{ira-conflicts.c}, @file{ira-color.c},
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 @file{ira-emit.c}, @file{ira-lives}, plus header files @file{ira.h}
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 and @file{ira-int.h} used for the communication between the allocator
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 and the rest of the compiler and between the IRA files.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 @cindex reloading
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 @item
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 Reloading. This pass renumbers pseudo registers with the hardware
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1110 registers numbers they were allocated. Pseudo registers that did not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 get hard registers are replaced with stack slots. Then it finds
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 instructions that are invalid because a value has failed to end up in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 a register, or has ended up in a register of the wrong kind. It fixes
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 up these instructions by reloading the problematical values
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 temporarily into registers. Additional instructions are generated to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 do the copying.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 The reload pass also optionally eliminates the frame pointer and inserts
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 instructions to save and restore call-clobbered registers around calls.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 Source files are @file{reload.c} and @file{reload1.c}, plus the header
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 @file{reload.h} used for communication between them.
111
kono
parents: 67
diff changeset
1123
kono
parents: 67
diff changeset
1124 @cindex Local Register Allocator (LRA)
kono
parents: 67
diff changeset
1125 @item
kono
parents: 67
diff changeset
1126 This pass is a modern replacement of the reload pass. Source files
kono
parents: 67
diff changeset
1127 are @file{lra.c}, @file{lra-assign.c}, @file{lra-coalesce.c},
kono
parents: 67
diff changeset
1128 @file{lra-constraints.c}, @file{lra-eliminations.c},
kono
parents: 67
diff changeset
1129 @file{lra-lives.c}, @file{lra-remat.c}, @file{lra-spills.c}, the
kono
parents: 67
diff changeset
1130 header @file{lra-int.h} used for communication between them, and the
kono
parents: 67
diff changeset
1131 header @file{lra.h} used for communication between LRA and the rest of
kono
parents: 67
diff changeset
1132 compiler.
kono
parents: 67
diff changeset
1133
kono
parents: 67
diff changeset
1134 Unlike the reload pass, intermediate LRA decisions are reflected in
kono
parents: 67
diff changeset
1135 RTL as much as possible. This reduces the number of target-dependent
kono
parents: 67
diff changeset
1136 macros and hooks, leaving instruction constraints as the primary
kono
parents: 67
diff changeset
1137 source of control.
kono
parents: 67
diff changeset
1138
kono
parents: 67
diff changeset
1139 LRA is run on targets for which TARGET_LRA_P returns true.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 @end itemize
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1141
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 @item Basic block reordering
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1144 This pass implements profile guided code positioning. If profile
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1145 information is not available, various types of static analysis are
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1146 performed to make the predictions normally coming from the profile
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1147 feedback (IE execution frequency, branch probability, etc). It is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 implemented in the file @file{bb-reorder.c}, and the various
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 prediction routines are in @file{predict.c}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151 @item Variable tracking
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 This pass computes where the variables are stored at each
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 position in code and generates notes describing the variable locations
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155 to RTL code. The location lists are then generated according to these
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 notes to debug information if the debugging information format supports
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1157 location lists. The code is located in @file{var-tracking.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159 @item Delayed branch scheduling
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161 This optional pass attempts to find instructions that can go into the
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1162 delay slots of other instructions, usually jumps and calls. The code
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1163 for this pass is located in @file{reorg.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 @item Branch shortening
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 On many RISC machines, branch instructions have a limited range.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 Thus, longer sequences of instructions must be used for long branches.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169 In this pass, the compiler figures out what how far each instruction
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 will be from each other instruction, and therefore whether the usual
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 instructions, or the longer sequences, must be used for each branch.
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1172 The code for this pass is located in @file{final.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 @item Register-to-stack conversion
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 Conversion from usage of some hard registers to usage of a register
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 stack may be done at this point. Currently, this is supported only
19
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1178 for the floating-point registers of the Intel 80387 coprocessor. The
58ad6c70ea60 update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
1179 code for this pass is located in @file{reg-stack.c}.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 @item Final
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 This pass outputs the assembler code for the function. The source files
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 are @file{final.c} plus @file{insn-output.c}; the latter is generated
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1185 automatically from the machine description by the tool @file{genoutput}.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 The header file @file{conditions.h} is used for communication between
111
kono
parents: 67
diff changeset
1187 these files.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 @item Debugging information output
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1190
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 This is run after final because it must output the stack slot offsets
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 for pseudo registers that did not get hard registers. Source files
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1193 are @file{dbxout.c} for DBX symbol table format, @file{dwarfout.c} for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1194 DWARF symbol table format, files @file{dwarf2out.c} and @file{dwarf2asm.c}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1195 for DWARF2 symbol table format, and @file{vmsdbgout.c} for VMS debug
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1196 symbol table format.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198 @end itemize
111
kono
parents: 67
diff changeset
1199
kono
parents: 67
diff changeset
1200 @node Optimization info
kono
parents: 67
diff changeset
1201 @section Optimization info
kono
parents: 67
diff changeset
1202 @include optinfo.texi