source: trunk/third/gcc/gcc.info-2 @ 11288

Revision 11288, 46.8 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r11287, which included commits to RCS files with non-trunk default branches.
Line 
1This is Info file gcc.info, produced by Makeinfo version 1.67 from the
2input file gcc.texi.
3
4   This file documents the use and the internals of the GNU compiler.
5
6   Published by the Free Software Foundation 59 Temple Place - Suite 330
7Boston, MA 02111-1307 USA
8
9   Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998
10Free Software Foundation, Inc.
11
12   Permission is granted to make and distribute verbatim copies of this
13manual provided the copyright notice and this permission notice are
14preserved on all copies.
15
16   Permission is granted to copy and distribute modified versions of
17this manual under the conditions for verbatim copying, provided also
18that the sections entitled "GNU General Public License," "Funding for
19Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
20included exactly as in the original, and provided that the entire
21resulting derived work is distributed under the terms of a permission
22notice identical to this one.
23
24   Permission is granted to copy and distribute translations of this
25manual into another language, under the above conditions for modified
26versions, except that the sections entitled "GNU General Public
27License," "Funding for Free Software," and "Protect Your Freedom--Fight
28`Look And Feel'", and this permission notice, may be included in
29translations approved by the Free Software Foundation instead of in the
30original English.
31
32
33File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
34
35Options to Request or Suppress Warnings
36=======================================
37
38   Warnings are diagnostic messages that report constructions which are
39not inherently erroneous but which are risky or suggest there may have
40been an error.
41
42   You can request many specific warnings with options beginning `-W',
43for example `-Wimplicit' to request warnings on implicit declarations.
44Each of these specific warning options also has a negative form
45beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
46This manual lists only one of the two forms, whichever is not the
47default.
48
49   These options control the amount and kinds of warnings produced by
50GNU CC:
51
52`-fsyntax-only'
53     Check the code for syntax errors, but don't do anything beyond
54     that.
55
56`-pedantic'
57     Issue all the warnings demanded by strict ANSI standard C; reject
58     all programs that use forbidden extensions.
59
60     Valid ANSI standard C programs should compile properly with or
61     without this option (though a rare few will require `-ansi').
62     However, without this option, certain GNU extensions and
63     traditional C features are supported as well.  With this option,
64     they are rejected.
65
66     `-pedantic' does not cause warning messages for use of the
67     alternate keywords whose names begin and end with `__'.  Pedantic
68     warnings are also disabled in the expression that follows
69     `__extension__'.  However, only system header files should use
70     these escape routes; application programs should avoid them.
71     *Note Alternate Keywords::.
72
73     This option is not intended to be useful; it exists only to satisfy
74     pedants who would otherwise claim that GNU CC fails to support the
75     ANSI standard.
76
77     Some users try to use `-pedantic' to check programs for strict ANSI
78     C conformance.  They soon find that it does not do quite what they
79     want: it finds some non-ANSI practices, but not all--only those
80     for which ANSI C *requires* a diagnostic.
81
82     A feature to report any failure to conform to ANSI C might be
83     useful in some instances, but would require considerable
84     additional work and would be quite different from `-pedantic'.  We
85     recommend, rather, that users take advantage of the extensions of
86     GNU C and disregard the limitations of other compilers.  Aside
87     from certain supercomputers and obsolete small machines, there is
88     less and less reason ever to use any other C compiler other than
89     for bootstrapping GNU CC.
90
91`-pedantic-errors'
92     Like `-pedantic', except that errors are produced rather than
93     warnings.
94
95`-w'
96     Inhibit all warning messages.
97
98`-Wno-import'
99     Inhibit warning messages about the use of `#import'.
100
101`-Wchar-subscripts'
102     Warn if an array subscript has type `char'.  This is a common cause
103     of error, as programmers often forget that this type is signed on
104     some machines.
105
106`-Wcomment'
107     Warn whenever a comment-start sequence `/*' appears in a `/*'
108     comment, or whenever a Backslash-Newline appears in a `//' comment.
109
110`-Wformat'
111     Check calls to `printf' and `scanf', etc., to make sure that the
112     arguments supplied have types appropriate to the format string
113     specified.
114
115`-Wimplicit-int'
116     Warn when a declaration does not specify a type.
117
118`-Wimplicit-function-declarations'
119     Warn whenever a function is used before being declared.
120
121`-Wimplicit'
122     Same as `-Wimplicit-int' `-Wimplicit-function-declaration'.
123
124`-Wmain'
125     Warn if the type of `main' is suspicious.  `main' should be a
126     function with external linkage, returning int, taking either zero
127     arguments, two, or three arguments of appropriate types.
128
129`-Wparentheses'
130     Warn if parentheses are omitted in certain contexts, such as when
131     there is an assignment in a context where a truth value is
132     expected, or when operators are nested whose precedence people
133     often get confused about.
134
135     Also warn about constructions where there may be confusion to which
136     `if' statement an `else' branch belongs.  Here is an example of
137     such a case:
138
139          {
140            if (a)
141              if (b)
142                foo ();
143            else
144              bar ();
145          }
146
147     In C, every `else' branch belongs to the innermost possible `if'
148     statement, which in this example is `if (b)'.  This is often not
149     what the programmer expected, as illustrated in the above example
150     by indentation the programmer chose.  When there is the potential
151     for this confusion, GNU C will issue a warning when this flag is
152     specified.  To eliminate the warning, add explicit braces around
153     the innermost `if' statement so there is no way the `else' could
154     belong to the enclosing `if'.  The resulting code would look like
155     this:
156
157          {
158            if (a)
159              {
160                if (b)
161                  foo ();
162                else
163                  bar ();
164              }
165          }
166
167`-Wreturn-type'
168     Warn whenever a function is defined with a return-type that
169     defaults to `int'.  Also warn about any `return' statement with no
170     return-value in a function whose return-type is not `void'.
171
172`-Wswitch'
173     Warn whenever a `switch' statement has an index of enumeral type
174     and lacks a `case' for one or more of the named codes of that
175     enumeration.  (The presence of a `default' label prevents this
176     warning.)  `case' labels outside the enumeration range also
177     provoke warnings when this option is used.
178
179`-Wtrigraphs'
180     Warn if any trigraphs are encountered (assuming they are enabled).
181
182`-Wunused'
183     Warn whenever a variable is unused aside from its declaration,
184     whenever a function is declared static but never defined, whenever
185     a label is declared but not used, and whenever a statement
186     computes a result that is explicitly not used.
187
188     In order to get a warning about an unused function parameter, you
189     must specify both `-W' and `-Wunused'.
190
191     To suppress this warning for an expression, simply cast it to
192     void.  For unused variables and parameters, use the `unused'
193     attribute (*note Variable Attributes::.).
194
195`-Wuninitialized'
196     An automatic variable is used without first being initialized.
197
198     These warnings are possible only in optimizing compilation,
199     because they require data flow information that is computed only
200     when optimizing.  If you don't specify `-O', you simply won't get
201     these warnings.
202
203     These warnings occur only for variables that are candidates for
204     register allocation.  Therefore, they do not occur for a variable
205     that is declared `volatile', or whose address is taken, or whose
206     size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
207     structures, unions or arrays, even when they are in registers.
208
209     Note that there may be no warning about a variable that is used
210     only to compute a value that itself is never used, because such
211     computations may be deleted by data flow analysis before the
212     warnings are printed.
213
214     These warnings are made optional because GNU CC is not smart
215     enough to see all the reasons why the code might be correct
216     despite appearing to have an error.  Here is one example of how
217     this can happen:
218
219          {
220            int x;
221            switch (y)
222              {
223              case 1: x = 1;
224                break;
225              case 2: x = 4;
226                break;
227              case 3: x = 5;
228              }
229            foo (x);
230          }
231
232     If the value of `y' is always 1, 2 or 3, then `x' is always
233     initialized, but GNU CC doesn't know this.  Here is another common
234     case:
235
236          {
237            int save_y;
238            if (change_y) save_y = y, y = new_y;
239            ...
240            if (change_y) y = save_y;
241          }
242
243     This has no bug because `save_y' is used only if it is set.
244
245     Some spurious warnings can be avoided if you declare all the
246     functions you use that never return as `noreturn'.  *Note Function
247     Attributes::.
248
249`-Wreorder (C++ only)'
250     Warn when the order of member initializers given in the code does
251     not match the order in which they must be executed.  For instance:
252
253          struct A {
254            int i;
255            int j;
256            A(): j (0), i (1) { }
257          };
258
259     Here the compiler will warn that the member initializers for `i'
260     and `j' will be rearranged to match the declaration order of the
261     members.
262
263`-Wtemplate-debugging'
264     When using templates in a C++ program, warn if debugging is not yet
265     fully available (C++ only).
266
267`-Wall'
268     All of the above `-W' options combined.  This enables all the
269     warnings about constructions that some users consider
270     questionable, and that are easy to avoid (or modify to prevent the
271     warning), even in conjunction with macros.
272
273   The following `-W...' options are not implied by `-Wall'.  Some of
274them warn about constructions that users generally do not consider
275questionable, but which occasionally you might wish to check for;
276others warn about constructions that are necessary or hard to avoid in
277some cases, and there is no simple way to modify the code to suppress
278the warning.
279
280`-W'
281     Print extra warning messages for these events:
282
283        * A nonvolatile automatic variable might be changed by a call to
284          `longjmp'.  These warnings as well are possible only in
285          optimizing compilation.
286
287          The compiler sees only the calls to `setjmp'.  It cannot know
288          where `longjmp' will be called; in fact, a signal handler
289          could call it at any point in the code.  As a result, you may
290          get a warning even when there is in fact no problem because
291          `longjmp' cannot in fact be called at the place which would
292          cause a problem.
293
294        * A function can return either with or without a value.
295          (Falling off the end of the function body is considered
296          returning without a value.)  For example, this function would
297          evoke such a warning:
298
299               foo (a)
300               {
301                 if (a > 0)
302                   return a;
303               }
304
305        * An expression-statement or the left-hand side of a comma
306          expression contains no side effects.  To suppress the
307          warning, cast the unused expression to void.  For example, an
308          expression such as `x[i,j]' will cause a warning, but
309          `x[(void)i,j]' will not.
310
311        * An unsigned value is compared against zero with `<' or `<='.
312
313        * A comparison like `x<=y<=z' appears; this is equivalent to
314          `(x<=y ? 1 : 0) <= z', which is a different interpretation
315          from that of ordinary mathematical notation.
316
317        * Storage-class specifiers like `static' are not the first
318          things in a declaration.  According to the C Standard, this
319          usage is obsolescent.
320
321        * If `-Wall' or `-Wunused' is also specified, warn about unused
322          arguments.
323
324        * A comparison between signed and unsigned values could produce
325          an incorrect result when the signed value is converted to
326          unsigned.  (But do not warn if `-Wno-sign-compare' is also
327          specified.)
328
329        * An aggregate has a partly bracketed initializer.  For
330          example, the following code would evoke such a warning,
331          because braces are missing around the initializer for `x.h':
332
333               struct s { int f, g; };
334               struct t { struct s h; int i; };
335               struct t x = { 1, 2, 3 };
336
337`-Wtraditional'
338     Warn about certain constructs that behave differently in
339     traditional and ANSI C.
340
341        * Macro arguments occurring within string constants in the
342          macro body.  These would substitute the argument in
343          traditional C, but are part of the constant in ANSI C.
344
345        * A function declared external in one block and then used after
346          the end of the block.
347
348        * A `switch' statement has an operand of type `long'.
349
350`-Wundef'
351     Warn if an undefined identifier is evaluated in an `#if' directive.
352
353`-Wshadow'
354     Warn whenever a local variable shadows another local variable.
355
356`-Wid-clash-LEN'
357     Warn whenever two distinct identifiers match in the first LEN
358     characters.  This may help you prepare a program that will compile
359     with certain obsolete, brain-damaged compilers.
360
361`-Wlarger-than-LEN'
362     Warn whenever an object of larger than LEN bytes is defined.
363
364`-Wpointer-arith'
365     Warn about anything that depends on the "size of" a function type
366     or of `void'.  GNU C assigns these types a size of 1, for
367     convenience in calculations with `void *' pointers and pointers to
368     functions.
369
370`-Wbad-function-cast'
371     Warn whenever a function call is cast to a non-matching type.  For
372     example, warn if `int malloc()' is cast to `anything *'.
373
374`-Wcast-qual'
375     Warn whenever a pointer is cast so as to remove a type qualifier
376     from the target type.  For example, warn if a `const char *' is
377     cast to an ordinary `char *'.
378
379`-Wcast-align'
380     Warn whenever a pointer is cast such that the required alignment
381     of the target is increased.  For example, warn if a `char *' is
382     cast to an `int *' on machines where integers can only be accessed
383     at two- or four-byte boundaries.
384
385`-Wwrite-strings'
386     Give string constants the type `const char[LENGTH]' so that
387     copying the address of one into a non-`const' `char *' pointer
388     will get a warning.  These warnings will help you find at compile
389     time code that can try to write into a string constant, but only
390     if you have been very careful about using `const' in declarations
391     and prototypes.  Otherwise, it will just be a nuisance; this is
392     why we did not make `-Wall' request these warnings.
393
394`-Wconversion'
395     Warn if a prototype causes a type conversion that is different
396     from what would happen to the same argument in the absence of a
397     prototype.  This includes conversions of fixed point to floating
398     and vice versa, and conversions changing the width or signedness
399     of a fixed point argument except when the same as the default
400     promotion.
401
402     Also, warn if a negative integer constant expression is implicitly
403     converted to an unsigned type.  For example, warn about the
404     assignment `x = -1' if `x' is unsigned.  But do not warn about
405     explicit casts like `(unsigned) -1'.
406
407`-Wsign-compare'
408     Warn when a comparison between signed and unsigned values could
409     produce an incorrect result when the signed value is converted to
410     unsigned.  This warning is also enabled by `-W'; to get the other
411     warnings of `-W' without this warning, use `-W -Wno-sign-compare'.
412
413`-Waggregate-return'
414     Warn if any functions that return structures or unions are defined
415     or called.  (In languages where you can return an array, this also
416     elicits a warning.)
417
418`-Wstrict-prototypes'
419     Warn if a function is declared or defined without specifying the
420     argument types.  (An old-style function definition is permitted
421     without a warning if preceded by a declaration which specifies the
422     argument types.)
423
424`-Wmissing-prototypes'
425     Warn if a global function is defined without a previous prototype
426     declaration.  This warning is issued even if the definition itself
427     provides a prototype.  The aim is to detect global functions that
428     fail to be declared in header files.
429
430`-Wmissing-declarations'
431     Warn if a global function is defined without a previous
432     declaration.  Do so even if the definition itself provides a
433     prototype.  Use this option to detect global functions that are
434     not declared in header files.
435
436`-Wredundant-decls'
437     Warn if anything is declared more than once in the same scope,
438     even in cases where multiple declaration is valid and changes
439     nothing.
440
441`-Wnested-externs'
442     Warn if an `extern' declaration is encountered within an function.
443
444`-Winline'
445     Warn if a function can not be inlined, and either it was declared
446     as inline, or else the `-finline-functions' option was given.
447
448`-Wold-style-cast'
449     Warn if an old-style (C-style) cast is used within a program.
450
451`-Woverloaded-virtual'
452     Warn when a derived class function declaration may be an error in
453     defining a virtual function (C++ only).  In a derived class, the
454     definitions of virtual functions must match the type signature of a
455     virtual function declared in the base class.  With this option, the
456     compiler warns when you define a function with the same name as a
457     virtual function, but with a type signature that does not match any
458     declarations from the base class.
459
460`-Wsynth (C++ only)'
461     Warn when g++'s synthesis behavior does not match that of cfront.
462     For instance:
463
464          struct A {
465            operator int ();
466            A& operator = (int);
467          };
468         
469          main ()
470          {
471            A a,b;
472            a = b;
473          }
474
475     In this example, g++ will synthesize a default `A& operator =
476     (const A&);', while cfront will use the user-defined `operator ='.
477
478`-Werror'
479     Make all warnings into errors.
480
481
482File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
483
484Options for Debugging Your Program or GNU CC
485============================================
486
487   GNU CC has various special options that are used for debugging
488either your program or GCC:
489
490`-g'
491     Produce debugging information in the operating system's native
492     format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
493     debugging information.
494
495     On most systems that use stabs format, `-g' enables use of extra
496     debugging information that only GDB can use; this extra information
497     makes debugging work better in GDB but will probably make other
498     debuggers crash or refuse to read the program.  If you want to
499     control for certain whether to generate the extra information, use
500     `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf-1+', or
501     `-gdwarf-1' (see below).
502
503     Unlike most other C compilers, GNU CC allows you to use `-g' with
504     `-O'.  The shortcuts taken by optimized code may occasionally
505     produce surprising results: some variables you declared may not
506     exist at all; flow of control may briefly move where you did not
507     expect it; some statements may not be executed because they
508     compute constant results or their values were already at hand;
509     some statements may execute in different places because they were
510     moved out of loops.
511
512     Nevertheless it proves possible to debug optimized output.  This
513     makes it reasonable to use the optimizer for programs that might
514     have bugs.
515
516     The following options are useful when GNU CC is generated with the
517     capability for more than one debugging format.
518
519`-ggdb'
520     Produce debugging information for use by GDB.  This means to use
521     the most expressive format available (DWARF 2, stabs, or the
522     native format if neither of those are supported), including GDB
523     extensions if at all possible.
524
525`-gstabs'
526     Produce debugging information in stabs format (if that is
527     supported), without GDB extensions.  This is the format used by
528     DBX on most BSD systems.  On MIPS, Alpha and System V Release 4
529     systems this option produces stabs debugging output which is not
530     understood by DBX or SDB.  On System V Release 4 systems this
531     option requires the GNU assembler.
532
533`-gstabs+'
534     Produce debugging information in stabs format (if that is
535     supported), using GNU extensions understood only by the GNU
536     debugger (GDB).  The use of these extensions is likely to make
537     other debuggers crash or refuse to read the program.
538
539`-gcoff'
540     Produce debugging information in COFF format (if that is
541     supported).  This is the format used by SDB on most System V
542     systems prior to System V Release 4.
543
544`-gxcoff'
545     Produce debugging information in XCOFF format (if that is
546     supported).  This is the format used by the DBX debugger on IBM
547     RS/6000 systems.
548
549`-gxcoff+'
550     Produce debugging information in XCOFF format (if that is
551     supported), using GNU extensions understood only by the GNU
552     debugger (GDB).  The use of these extensions is likely to make
553     other debuggers crash or refuse to read the program, and may cause
554     assemblers other than the GNU assembler (GAS) to fail with an
555     error.
556
557`-gdwarf'
558     Produce debugging information in DWARF version 1 format (if that is
559     supported).  This is the format used by SDB on most System V
560     Release 4 systems.
561
562`-gdwarf+'
563     Produce debugging information in DWARF version 1 format (if that is
564     supported), using GNU extensions understood only by the GNU
565     debugger (GDB).  The use of these extensions is likely to make
566     other debuggers crash or refuse to read the program.
567
568`-gdwarf-2'
569     Produce debugging information in DWARF version 2 format (if that is
570     supported).  This is the format used by DBX on IRIX 6.
571
572`-gLEVEL'
573`-ggdbLEVEL'
574`-gstabsLEVEL'
575`-gcoffLEVEL'
576`-gxcoffLEVEL'
577`-gdwarfLEVEL'
578`-gdwarf-2LEVEL'
579     Request debugging information and also use LEVEL to specify how
580     much information.  The default level is 2.
581
582     Level 1 produces minimal information, enough for making backtraces
583     in parts of the program that you don't plan to debug.  This
584     includes descriptions of functions and external variables, but no
585     information about local variables and no line numbers.
586
587     Level 3 includes extra information, such as all the macro
588     definitions present in the program.  Some debuggers support macro
589     expansion when you use `-g3'.
590
591`-p'
592     Generate extra code to write profile information suitable for the
593     analysis program `prof'.  You must use this option when compiling
594     the source files you want data about, and you must also use it when
595     linking.
596
597`-pg'
598     Generate extra code to write profile information suitable for the
599     analysis program `gprof'.  You must use this option when compiling
600     the source files you want data about, and you must also use it when
601     linking.
602
603`-a'
604     Generate extra code to write profile information for basic blocks,
605     which will record the number of times each basic block is
606     executed, the basic block start address, and the function name
607     containing the basic block.  If `-g' is used, the line number and
608     filename of the start of the basic block will also be recorded.
609     If not overridden by the machine description, the default action is
610     to append to the text file `bb.out'.
611
612     This data could be analyzed by a program like `tcov'.  Note,
613     however, that the format of the data is not what `tcov' expects.
614     Eventually GNU `gprof' should be extended to process this data.
615
616`-ax'
617     Generate extra code to profile basic blocks.  Your executable will
618     produce output that is a superset of that produced when `-a' is
619     used.  Additional output is the source and target address of the
620     basic blocks where a jump takes place, the number of times a jump
621     is executed, and (optionally) the complete sequence of basic
622     blocks being executed.  The output is appended to file `bb.out'.
623
624     You can examine different profiling aspects without recompilation.
625     Your executable will read a list of function names from file
626     `bb.in'.  Profiling starts when a function on the list is entered
627     and stops when that invocation is exited.  To exclude a function
628     from profiling, prefix its name with `-'.  If a function name is
629     not unique, you can disambiguate it by writing it in the form
630     `/path/filename.d:functionname'.  Your executable will write the
631     available paths and filenames in file `bb.out'.
632
633     Several function names have a special meaning:
634    `__bb_jumps__'
635          Write source, target and frequency of jumps to file `bb.out'.
636
637    `__bb_hidecall__'
638          Exclude function calls from frequency count.
639
640    `__bb_showret__'
641          Include function returns in frequency count.
642
643    `__bb_trace__'
644          Write the sequence of basic blocks executed to file
645          `bbtrace.gz'.  The file will be compressed using the program
646          `gzip', which must exist in your `PATH'.  On systems without
647          the `popen' function, the file will be named `bbtrace' and
648          will not be compressed.  *Profiling for even a few seconds on
649          these systems will produce a very large file.*  Note:
650          `__bb_hidecall__' and `__bb_showret__' will not affect the
651          sequence written to `bbtrace.gz'.
652
653     Here's a short example using different profiling parameters in
654     file `bb.in'.  Assume function `foo' consists of basic blocks 1
655     and 2 and is called twice from block 3 of function `main'.  After
656     the calls, block 3 transfers control to block 4 of `main'.
657
658     With `__bb_trace__' and `main' contained in file `bb.in', the
659     following sequence of blocks is written to file `bbtrace.gz': 0 3
660     1 2 1 2 4.  The return from block 2 to block 3 is not shown,
661     because the return is to a point inside the block and not to the
662     top.  The block address 0 always indicates, that control is
663     transferred to the trace from somewhere outside the observed
664     functions.  With `-foo' added to `bb.in', the blocks of function
665     `foo' are removed from the trace, so only 0 3 4 remains.
666
667     With `__bb_jumps__' and `main' contained in file `bb.in', jump
668     frequencies will be written to file `bb.out'.  The frequencies are
669     obtained by constructing a trace of blocks and incrementing a
670     counter for every neighbouring pair of blocks in the trace.  The
671     trace 0 3 1 2 1 2 4 displays the following frequencies:
672
673          Jump from block 0x0 to block 0x3 executed 1 time(s)
674          Jump from block 0x3 to block 0x1 executed 1 time(s)
675          Jump from block 0x1 to block 0x2 executed 2 time(s)
676          Jump from block 0x2 to block 0x1 executed 1 time(s)
677          Jump from block 0x2 to block 0x4 executed 1 time(s)
678
679     With `__bb_hidecall__', control transfer due to call instructions
680     is removed from the trace, that is the trace is cut into three
681     parts: 0 3 4, 0 1 2 and 0 1 2.  With `__bb_showret__', control
682     transfer due to return instructions is added to the trace.  The
683     trace becomes: 0 3 1 2 3 1 2 3 4.  Note, that this trace is not
684     the same, as the sequence written to `bbtrace.gz'.  It is solely
685     used for counting jump frequencies.
686
687`-fprofile-arcs'
688     Instrument "arcs" during compilation.  For each function of your
689     program, GNU CC creates a program flow graph, then finds a
690     spanning tree for the graph.  Only arcs that are not on the
691     spanning tree have to be instrumented: the compiler adds code to
692     count the number of times that these arcs are executed.  When an
693     arc is the only exit or only entrance to a block, the
694     instrumentation code can be added to the block; otherwise, a new
695     basic block must be created to hold the instrumentation code.
696
697     Since not every arc in the program must be instrumented, programs
698     compiled with this option run faster than programs compiled with
699     `-a', which adds instrumentation code to every basic block in the
700     program.  The tradeoff: since `gcov' does not have execution
701     counts for all branches, it must start with the execution counts
702     for the instrumented branches, and then iterate over the program
703     flow graph until the entire graph has been solved.  Hence, `gcov'
704     runs a little more slowly than a program which uses information
705     from `-a'.
706
707     `-fprofile-arcs' also makes it possible to estimate branch
708     probabilities, and to calculate basic block execution counts.  In
709     general, basic block execution counts do not give enough
710     information to estimate all branch probabilities.  When the
711     compiled program exits, it saves the arc execution counts to a
712     file called `SOURCENAME.da'.  Use the compiler option
713     `-fbranch-probabilities' (*note Options that Control Optimization:
714     Optimize Options.) when recompiling, to optimize using estimated
715     branch probabilities.
716
717`-ftest-coverage'
718     Create data files for the `gcov' code-coverage utility (*note
719     `gcov': a GNU CC Test Coverage Program: Gcov.).  The data file
720     names begin with the name of your source file:
721
722    `SOURCENAME.bb'
723          A mapping from basic blocks to line numbers, which `gcov'
724          uses to associate basic block execution counts with line
725          numbers.
726
727    `SOURCENAME.bbg'
728          A list of all arcs in the program flow graph.  This allows
729          `gcov' to reconstruct the program flow graph, so that it can
730          compute all basic block and arc execution counts from the
731          information in the `SOURCENAME.da' file (this last file is
732          the output from `-fprofile-arcs').
733
734`-Q'
735     Makes the compiler print out each function name as it is compiled,
736     and print some statistics about each pass when it finishes.
737
738`-dLETTERS'
739     Says to make debugging dumps during compilation at times specified
740     by LETTERS.  This is used for debugging the compiler.  The file
741     names for most of the dumps are made by appending a word to the
742     source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
743     possible letters for use in LETTERS, and their meanings:
744
745    `M'
746          Dump all macro definitions, at the end of preprocessing, and
747          write no output.
748
749    `N'
750          Dump all macro names, at the end of preprocessing.
751
752    `D'
753          Dump all macro definitions, at the end of preprocessing, in
754          addition to normal output.
755
756    `y'
757          Dump debugging information during parsing, to standard error.
758
759    `r'
760          Dump after RTL generation, to `FILE.rtl'.
761
762    `x'
763          Just generate RTL for a function instead of compiling it.
764          Usually used with `r'.
765
766    `j'
767          Dump after first jump optimization, to `FILE.jump'.
768
769    `s'
770          Dump after CSE (including the jump optimization that sometimes
771          follows CSE), to `FILE.cse'.
772
773    `D'
774          Dump after purging ADDRESSOF, to `FILE.addressof'.
775
776    `L'
777          Dump after loop optimization, to `FILE.loop'.
778
779    `t'
780          Dump after the second CSE pass (including the jump
781          optimization that sometimes follows CSE), to `FILE.cse2'.
782
783    `b'
784          Dump after computing branch probabilities, to `FILE.bp'.
785
786    `f'
787          Dump after flow analysis, to `FILE.flow'.
788
789    `c'
790          Dump after instruction combination, to the file
791          `FILE.combine'.
792
793    `S'
794          Dump after the first instruction scheduling pass, to
795          `FILE.sched'.
796
797    `l'
798          Dump after local register allocation, to `FILE.lreg'.
799
800    `g'
801          Dump after global register allocation, to `FILE.greg'.
802
803    `R'
804          Dump after the second instruction scheduling pass, to
805          `FILE.sched2'.
806
807    `J'
808          Dump after last jump optimization, to `FILE.jump2'.
809
810    `d'
811          Dump after delayed branch scheduling, to `FILE.dbr'.
812
813    `k'
814          Dump after conversion from registers to stack, to
815          `FILE.stack'.
816
817    `a'
818          Produce all the dumps listed above.
819
820    `m'
821          Print statistics on memory usage, at the end of the run, to
822          standard error.
823
824    `p'
825          Annotate the assembler output with a comment indicating which
826          pattern and alternative was used.
827
828    `A'
829          Annotate the assembler output with miscellaneous debugging
830          information.
831
832`-fpretend-float'
833     When running a cross-compiler, pretend that the target machine
834     uses the same floating point format as the host machine.  This
835     causes incorrect output of the actual floating constants, but the
836     actual instruction sequence will probably be the same as GNU CC
837     would make when running on the target machine.
838
839`-save-temps'
840     Store the usual "temporary" intermediate files permanently; place
841     them in the current directory and name them based on the source
842     file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
843     files `foo.i' and `foo.s', as well as `foo.o'.
844
845`-print-file-name=LIBRARY'
846     Print the full absolute name of the library file LIBRARY that
847     would be used when linking--and don't do anything else.  With this
848     option, GNU CC does not compile or link anything; it just prints
849     the file name.
850
851`-print-prog-name=PROGRAM'
852     Like `-print-file-name', but searches for a program such as `cpp'.
853
854`-print-libgcc-file-name'
855     Same as `-print-file-name=libgcc.a'.
856
857     This is useful when you use `-nostdlib' or `-nodefaultlibs' but
858     you do want to link with `libgcc.a'.  You can do
859
860          gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
861
862`-print-search-dirs'
863     Print the name of the configured installation directory and a list
864     of program and library directories gcc will search--and don't do
865     anything else.
866
867     This is useful when gcc prints the error message `installation
868     problem, cannot exec cpp: No such file or directory'.  To resolve
869     this you either need to put `cpp' and the other compiler
870     components where gcc expects to find them, or you can set the
871     environment variable `GCC_EXEC_PREFIX' to the directory where you
872     installed them.  Don't forget the trailing '/'.  *Note Environment
873     Variables::.
874
875
876File: gcc.info,  Node: Optimize Options,  Next: Preprocessor Options,  Prev: Debugging Options,  Up: Invoking GCC
877
878Options That Control Optimization
879=================================
880
881   These options control various sorts of optimizations:
882
883`-O'
884`-O1'
885     Optimize.  Optimizing compilation takes somewhat more time, and a
886     lot more memory for a large function.
887
888     Without `-O', the compiler's goal is to reduce the cost of
889     compilation and to make debugging produce the expected results.
890     Statements are independent: if you stop the program with a
891     breakpoint between statements, you can then assign a new value to
892     any variable or change the program counter to any other statement
893     in the function and get exactly the results you would expect from
894     the source code.
895
896     Without `-O', the compiler only allocates variables declared
897     `register' in registers.  The resulting compiled code is a little
898     worse than produced by PCC without `-O'.
899
900     With `-O', the compiler tries to reduce code size and execution
901     time.
902
903     When you specify `-O', the compiler turns on `-fthread-jumps' and
904     `-fdefer-pop' on all machines.  The compiler turns on
905     `-fdelayed-branch' on machines that have delay slots, and
906     `-fomit-frame-pointer' on machines that can support debugging even
907     without a frame pointer.  On some machines the compiler also turns
908     on other flags.
909
910`-O2'
911     Optimize even more.  GNU CC performs nearly all supported
912     optimizations that do not involve a space-speed tradeoff.  The
913     compiler does not perform loop unrolling or function inlining when
914     you specify `-O2'.  As compared to `-O', this option increases
915     both compilation time and the performance of the generated code.
916
917     `-O2' turns on all optional optimizations except for loop unrolling
918     and function inlining.  It also turns on the `-fforce-mem' option
919     on all machines and frame pointer elimination on machines where
920     doing so does not interfere with debugging.
921
922`-O3'
923     Optimize yet more.  `-O3' turns on all optimizations specified by
924     `-O2' and also turns on the `inline-functions' option.
925
926`-O0'
927     Do not optimize.
928
929     If you use multiple `-O' options, with or without level numbers,
930     the last such option is the one that is effective.
931
932   Options of the form `-fFLAG' specify machine-independent flags.
933Most flags have both positive and negative forms; the negative form of
934`-ffoo' would be `-fno-foo'.  In the table below, only one of the forms
935is listed--the one which is not the default.  You can figure out the
936other form by either removing `no-' or adding it.
937
938`-ffloat-store'
939     Do not store floating point variables in registers, and inhibit
940     other options that might change whether a floating point value is
941     taken from a register or memory.
942
943     This option prevents undesirable excess precision on machines such
944     as the 68000 where the floating registers (of the 68881) keep more
945     precision than a `double' is supposed to have.  Similarly for the
946     x86 architecture.  For most programs, the excess precision does
947     only good, but a few programs rely on the precise definition of
948     IEEE floating point.  Use `-ffloat-store' for such programs.
949
950`-fno-default-inline'
951     Do not make member functions inline by default merely because they
952     are defined inside the class scope (C++ only).  Otherwise, when
953     you specify `-O', member functions defined inside class scope are
954     compiled inline by default; i.e., you don't need to add `inline'
955     in front of the member function name.
956
957`-fno-defer-pop'
958     Always pop the arguments to each function call as soon as that
959     function returns.  For machines which must pop arguments after a
960     function call, the compiler normally lets arguments accumulate on
961     the stack for several function calls and pops them all at once.
962
963`-fforce-mem'
964     Force memory operands to be copied into registers before doing
965     arithmetic on them.  This produces better code by making all memory
966     references potential common subexpressions.  When they are not
967     common subexpressions, instruction combination should eliminate
968     the separate register-load.  The `-O2' option turns on this option.
969
970`-fforce-addr'
971     Force memory address constants to be copied into registers before
972     doing arithmetic on them.  This may produce better code just as
973     `-fforce-mem' may.
974
975`-fomit-frame-pointer'
976     Don't keep the frame pointer in a register for functions that
977     don't need one.  This avoids the instructions to save, set up and
978     restore frame pointers; it also makes an extra register available
979     in many functions.  *It also makes debugging impossible on some
980     machines.*
981
982     On some machines, such as the Vax, this flag has no effect, because
983     the standard calling sequence automatically handles the frame
984     pointer and nothing is saved by pretending it doesn't exist.  The
985     machine-description macro `FRAME_POINTER_REQUIRED' controls
986     whether a target machine supports this flag.  *Note Registers::.
987
988`-fno-inline'
989     Don't pay attention to the `inline' keyword.  Normally this option
990     is used to keep the compiler from expanding any functions inline.
991     Note that if you are not optimizing, no functions can be expanded
992     inline.
993
994`-finline-functions'
995     Integrate all simple functions into their callers.  The compiler
996     heuristically decides which functions are simple enough to be worth
997     integrating in this way.
998
999     If all calls to a given function are integrated, and the function
1000     is declared `static', then the function is normally not output as
1001     assembler code in its own right.
1002
1003`-fkeep-inline-functions'
1004     Even if all calls to a given function are integrated, and the
1005     function is declared `static', nevertheless output a separate
1006     run-time callable version of the function.  This switch does not
1007     affect `extern inline' functions.
1008
1009`-fkeep-static-consts'
1010     Emit variables declared `static const' when optimization isn't
1011     turned on, even if the variables aren't referenced.
1012
1013     GNU CC enables this option by default.  If you want to force the
1014     compiler to check if the variable was referenced, regardless of
1015     whether or not optimization is turned on, use the
1016     `-fno-keep-static-consts' option.
1017
1018`-fno-function-cse'
1019     Do not put function addresses in registers; make each instruction
1020     that calls a constant function contain the function's address
1021     explicitly.
1022
1023     This option results in less efficient code, but some strange hacks
1024     that alter the assembler output may be confused by the
1025     optimizations performed when this option is not used.
1026
1027`-ffast-math'
1028     This option allows GCC to violate some ANSI or IEEE rules and/or
1029     specifications in the interest of optimizing code for speed.  For
1030     example, it allows the compiler to assume arguments to the `sqrt'
1031     function are non-negative numbers and that no floating-point values
1032     are NaNs.
1033
1034     This option should never be turned on by any `-O' option since it
1035     can result in incorrect output for programs which depend on an
1036     exact implementation of IEEE or ANSI rules/specifications for math
1037     functions.
1038
1039   The following options control specific optimizations.  The `-O2'
1040option turns on all of these optimizations except `-funroll-loops' and
1041`-funroll-all-loops'.  On most machines, the `-O' option turns on the
1042`-fthread-jumps' and `-fdelayed-branch' options, but specific machines
1043may handle it differently.
1044
1045   You can use the following flags in the rare cases when "fine-tuning"
1046of optimizations to be performed is desired.
1047
1048`-fstrength-reduce'
1049     Perform the optimizations of loop strength reduction and
1050     elimination of iteration variables.
1051
1052`-fthread-jumps'
1053     Perform optimizations where we check to see if a jump branches to a
1054     location where another comparison subsumed by the first is found.
1055     If so, the first branch is redirected to either the destination of
1056     the second branch or a point immediately following it, depending
1057     on whether the condition is known to be true or false.
1058
1059`-fcse-follow-jumps'
1060     In common subexpression elimination, scan through jump instructions
1061     when the target of the jump is not reached by any other path.  For
1062     example, when CSE encounters an `if' statement with an `else'
1063     clause, CSE will follow the jump when the condition tested is
1064     false.
1065
1066`-fcse-skip-blocks'
1067     This is similar to `-fcse-follow-jumps', but causes CSE to follow
1068     jumps which conditionally skip over blocks.  When CSE encounters a
1069     simple `if' statement with no else clause, `-fcse-skip-blocks'
1070     causes CSE to follow the jump around the body of the `if'.
1071
1072`-frerun-cse-after-loop'
1073     Re-run common subexpression elimination after loop optimizations
1074     has been performed.
1075
1076`-fexpensive-optimizations'
1077     Perform a number of minor optimizations that are relatively
1078     expensive.
1079
1080`-fdelayed-branch'
1081     If supported for the target machine, attempt to reorder
1082     instructions to exploit instruction slots available after delayed
1083     branch instructions.
1084
1085`-fschedule-insns'
1086     If supported for the target machine, attempt to reorder
1087     instructions to eliminate execution stalls due to required data
1088     being unavailable.  This helps machines that have slow floating
1089     point or memory load instructions by allowing other instructions
1090     to be issued until the result of the load or floating point
1091     instruction is required.
1092
1093`-fschedule-insns2'
1094     Similar to `-fschedule-insns', but requests an additional pass of
1095     instruction scheduling after register allocation has been done.
1096     This is especially useful on machines with a relatively small
1097     number of registers and where memory load instructions take more
1098     than one cycle.
1099
1100`-ffunction-sections'
1101     Place each function into its own section in the output file if the
1102     target supports arbitrary sections.  The function's name determines
1103     the section's name in the output file.
1104
1105     Use this option on systems where the linker can perform
1106     optimizations to improve locality of reference in the instruction
1107     space.  HPPA processors running HP-UX and Sparc processors running
1108     Solaris 2 have linkers with such optimizations.  Other systems
1109     using the ELF object format as well as AIX may have these
1110     optimizations in the future.
1111
1112     Only use this option when there are significant benefits from doing
1113     so.  When you specify this option, the assembler and linker will
1114     create larger object and executable files and will also be slower.
1115     You will not be able to use `gprof' on all systems if you specify
1116     this option and you may have problems with debugging if you
1117     specify both this option and `-g'.
1118
1119`-fcaller-saves'
1120     Enable values to be allocated in registers that will be clobbered
1121     by function calls, by emitting extra instructions to save and
1122     restore the registers around such calls.  Such allocation is done
1123     only when it seems to result in better code than would otherwise
1124     be produced.
1125
1126     This option is enabled by default on certain machines, usually
1127     those which have no call-preserved registers to use instead.
1128
1129`-funroll-loops'
1130     Perform the optimization of loop unrolling.  This is only done for
1131     loops whose number of iterations can be determined at compile time
1132     or run time.  `-funroll-loop' implies both `-fstrength-reduce' and
1133     `-frerun-cse-after-loop'.
1134
1135`-funroll-all-loops'
1136     Perform the optimization of loop unrolling.  This is done for all
1137     loops and usually makes programs run more slowly.
1138     `-funroll-all-loops' implies `-fstrength-reduce' as well as
1139     `-frerun-cse-after-loop'.
1140
1141`-fno-peephole'
1142     Disable any machine-specific peephole optimizations.
1143
1144`-fbranch-probabilities'
1145     After running a program compiled with `-fprofile-arcs' (*note
1146     Options for Debugging Your Program or `gcc': Debugging Options.),
1147     you can compile it a second time using `-fbranch-probabilities',
1148     to improve optimizations based on guessing the path a branch might
1149     take.
1150
1151     With `-fbranch-probabilities', GNU CC puts a `REG_EXEC_COUNT' note
1152     on the first instruction of each basic block, and a `REG_BR_PROB'
1153     note on each `JUMP_INSN' and `CALL_INSN'.  These can be used to
1154     improve optimization.  Currently, they are only used in one place:
1155     in `reorg.c', instead of guessing which path a branch is mostly to
1156     take, the `REG_BR_PROB' values are used to exactly determine which
1157     path is taken more often.
1158
Note: See TracBrowser for help on using the repository browser.