Re: Optimizing empty functions in C

"Peter L. Montgomery" <Peter-Lawrence.Montgomery@cwi.nl>
28 Jun 2002 18:21:58 -0400

          From comp.compilers

Related articles
[9 earlier articles]
Re: Optimizing empty functions in C mlacey@microsoft.com (Mark Lacey \[MSFT\]) (2002-06-20)
Re: Optimizing empty functions in C dnovillo@redhat.com (Diego Novillo) (2002-06-28)
Re: Optimizing empty functions in C snicol@apk.net (Scott Nicol) (2002-06-28)
Re: Optimizing empty functions in C haberg@matematik.su.se (Hans Aberg) (2002-06-28)
Re: Optimizing empty functions in C ralph@inputplus.co.uk (Ralph Corderoy) (2002-06-28)
Re: Optimizing empty functions in C iddw@hotmail.com (Dave Hansen) (2002-06-28)
Re: Optimizing empty functions in C Peter-Lawrence.Montgomery@cwi.nl (Peter L. Montgomery) (2002-06-28)
Re: Optimizing empty functions in C fjh@cs.mu.OZ.AU (Fergus Henderson) (2002-07-02)
| List of all articles for this month |

From: "Peter L. Montgomery" <Peter-Lawrence.Montgomery@cwi.nl>
Newsgroups: comp.compilers
Date: 28 Jun 2002 18:21:58 -0400
Organization: CWI, Amsterdam
References: 02-06-025 02-06-042 02-06-068
Keywords: C, optimize
Posted-Date: 28 Jun 2002 18:21:58 EDT

"Mark Lacey \[MSFT\]" <mlacey@microsoft.com> writes:
>> [What do C++ compilers do? Identical functions in C++ are pretty common
>> when using templates, particularly templates for container classes that
>> don't interpret the data they're containing. -John]
>
>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? */


#include <stdio.h>


static int twice_1(int x) {return 2*x;}
static int twice_2(int x) {return 2*x;}


int main(void)
{
        printf("twice_1 = %p, twice_2 = %p, %s\n", twice_1, twice_2,
              (twice_1 == twice_2 ? "same" : "different"));


        return 0;
}
--
                Peter-Lawrence.Montgomery@cwi.nl Home: San Rafael, California
                Microsoft Research and CWI
[A footnote in C99 says "There is no linkage between different identifiers."
so I believe the intention is that different functions have different
addresses. -John]



Post a followup to this message

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