Mark Wagner wrote:
> On Fri, Apr 1, 2011 at 03:28, simagin <clonfsp@...> wrote:
>> If I have a function implemented in a .c file, with its .h definition, but I
>> dont call that funcion in my program, does it will be included in the output
>> exe file?
> This is called "dead code stripping". Some compilers/linkers do it,
> while some don't. I don't know what MinGW does.
Yes, there are attempts to remove dead code if the correct compiler
options are given. From the GCC documentation pages, found here
http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, we have:
Perform dead code elimination (DCE) on RTL. Enabled by default at -O and
Perform dead store elimination (DSE) on RTL. Enabled by default at -O
Perform dead code elimination (DCE) on trees. This flag is enabled by
default at -O and higher.
Perform conditional dead code elimination (DCE) for calls to builtin
functions that may set errno but are otherwise side-effect free. This
flag is enabled by default at -O2 and higher if -Os is not also specified.
Perform dead store elimination (DSE) on trees. A dead store is a store
into a memory location which will later be overwritten by another store
without any intervening loads. In this case the earlier store can be
deleted. This flag is enabled by default at -O and higher.
Enable the identity transformation for graphite. For every SCoP we
generate the polyhedral representation and transform it back to gimple.
Using -fgraphite-identity we can check the costs or benefits of the
GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
are also performed by the code generator CLooG, like index splitting and
dead code elimination in loops.
Constructs webs as commonly used for register allocation purposes and
assign each web individual pseudo register. This allows the register
allocation pass to operate on pseudos directly, but also strengthens
several other optimization passes, such as CSE, loop optimizer and
trivial dead code remover. It can, however, make debugging impossible,
since variables will no longer stay in a “home register”.
Enabled by default with -funroll-loops.