According to the GCC manual, the -fipa-pta
optimization does:
-fipa-pta
: Perform interprocedural pointer analysis and interprocedural modification and reference analysis. This option can cause excessive memory and compile-time usage on large compilation units. It is not enabled by default at any optimization level.
What I assume is that GCC tries to differentiate mutable and immutable data based on pointers and references used in a procedure. Can someone with more in-depth GCC knowledge explain what -fipa-pta
does?
gcc -c compiles source files without linking.
Meaning of the GCC in English abbreviation for Gulf Cooperation Council: a group of six countries in the Persian Gulf: Bahrain, Kuwait, Qatar, Oman, Saudi Arabia, and the United Arab Emirates. GCC countries make decisions together on trade, military spending, etc. Want to learn more?
GCC stands for “GNU Compiler Collection”. GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Fortran, Ada, D, and Go.
GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++.
Options: Description: Gcc –c: Compiles source files to object files without linking to any other object files. gcc –Idir: Includes the directories of header files: gcc –llib: link the code with the library files: gcc -o output file: Build the output generated to output file: gcc –w: Disables all warning messages during the compilation. gcc –Wall
GCC Command Options When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -coption says not to run the linker.
This is the same as specifying file as the second non-option argument to cpp. gcc has a different interpretation of a second non-option argument, so you must use '-o' to specify the output file. Turns on all optional warnings which are desirable for normal code. At present this is '-Wcomment' and '-Wtrigraphs'.
1. Specify the Output Executable Name. In its most basic form, gcc compiler can be used as : gcc main.c. The above command executes the complete compilation process and outputs an executable with name a.out. Use option -o, as shown below, to specify the output file name for the executable. gcc main.c -o main. The command above would produce an ...
I think the word "interprocedural" is the key here.
I'm not intimately familiar with gcc's optimizer, but I've worked on optimizing compilers before. The following is somewhat speculative; take it with a small grain of salt, or confirm it with someone who knows gcc's internals.
An optimizing compiler typically performs analysis and optimization only within each individual function (or subroutine, or procedure, depending on the language). For example, given code like this contrived example:
double *ptr = ...;
void foo(void) {
...
*ptr = 123.456;
some_other_function();
printf("*ptr = %f\n", *ptr);
}
the optimizer will not be able to determine whether the value of *ptr
has been changed by the call to some_other_function()
.
If interprocedural analysis is enabled, then the optimizer can analyze the behavior of some_other_function()
, and it may be able to prove that it can't modify *ptr
. Given such analysis, it can determine that the expression *ptr
must still evaluate to 123.456
, and in principle it could even replace the printf
call with puts("ptr = 123.456");
.
(In fact, with a small program similar to the above code snippet I got the same generated code with -O3
and -O3 -fipa-pta
, so I'm probably missing something.)
Since a typical program contains a large number of functions, with a huge number of possible call sequences, this kind of analysis can be very expensive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With