Re: Optimizing empty functions in C

"Fergus Henderson" <>
2 Jul 2002 01:15:45 -0400

          From comp.compilers

Related articles
Optimizing empty functions in C (Andrzej Wasowski) (2002-06-13)
Re: Optimizing empty functions in C (Joachim Durchholz) (2002-06-14)
Re: Optimizing empty functions in C (Mark Lacey \[MSFT\]) (2002-06-20)
Re: Optimizing empty functions in C (Peter L. Montgomery) (2002-06-28)
Re: Optimizing empty functions in C (Fergus Henderson) (2002-07-02)
| List of all articles for this month |

From: "Fergus Henderson" <>
Newsgroups: comp.compilers
Date: 2 Jul 2002 01:15:45 -0400
Organization: Computer Science, University of Melbourne
References: 02-06-025 02-06-042 02-06-068 02-06-081
Keywords: C, optimize
Posted-Date: 02 Jul 2002 01:15:44 EDT

"Peter L. Montgomery" <> writes:

>"Mark Lacey \[MSFT\]" <> writes:
>>The Microsoft Visual C++ toolset will eliminate duplicated functions
>>through a process it calls "identical COMDAT folding" (ICF). By
>>specifying -O1 or -O2 for the compilation and -opt:icf as a link
>>option, you get this effect. For elimination of (statically)
>>unreferenced functions, you again need either -O1 or -O2 on the
>>compilation and -opt:ref as a link option. -opt:ref implies -opt:icf
>>by default.
>/* Does standard C require twice_1 to compare unequal to twice_2? */

Yes, it does. So a conforming compiler can't treat them as identical.

It can however replace the body of one function with a jump to the
other one. This achieves most of the space savings from merging
duplicate functions (e.g. those that arise from C++ templates), albeit
at the cost of a small increase in execution time for the extra jumps,
which may be outweighed by the reduction in icache misses.

Fergus Henderson <> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <> | -- the last words of T. S. Garp.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.