From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26805 invoked by alias); 7 Jul 2002 19:17:26 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 26798 invoked from network); 7 Jul 2002 19:17:24 -0000 Received: from unknown (HELO mail.wrs.com) (147.11.1.11) by sources.redhat.com with SMTP; 7 Jul 2002 19:17:24 -0000 Received: from kankakee.wrs.com (kankakee [147.11.37.13]) by mail.wrs.com (8.9.3/8.9.1) with ESMTP id MAA14123; Sun, 7 Jul 2002 12:15:46 -0700 (PDT) From: mike stump Received: (from mrs@localhost) by kankakee.wrs.com (8.9.3+Sun/8.9.0) id MAA07105; Sun, 7 Jul 2002 12:17:19 -0700 (PDT) Date: Sun, 07 Jul 2002 15:45:00 -0000 Message-Id: <200207071917.MAA07105@kankakee.wrs.com> To: gcc@gcc.gnu.org, wink@saville.com Subject: Re: More space efficient virtual function calls References: <013001c2254d$53154e90$1200a8c0@saville.com> X-SW-Source: 2002-07/txt/msg00321.txt.bz2 > From: "Wink Saville" > To: > Date: Sat, 6 Jul 2002 17:29:11 -0700 > I was wondering if there was switch in gcc that would cause it to > generate smaller code when invoking virtual functions. Most likely not, other than -Os. > Is this already possible with an existing switch/pragma? No. > Is this practical? Yes. > Would most of the modifications be need to needed to the front end, back end > or both? It could be done in the port file. > Could someone point me to the places I would need to change to try this out? Sure. Just create a peephole to find the code you want to replace: > LDR R1,[R4] /* Fetch the vtable pointer */ > MOV R0,R4 /* R0 = this */ > MOV LR, PC /* Set of the link register */ > LDR PC,[R1, #4] /* Call virtual function 1, the second entry */ and replace it with what you want: > LDR R0,R4 /* R0 = this */ > BL __VTFunc1 /* Branch and Link to virtual thunk function 1 */ [ or whatever the right version is ], and do this when -Os is given. You should then be able to `see' the compiler generate this code. Then you will discover there is no definition for __VTFunc1, and you will discover you want to added it to the .asm or .s file for the port so it will wind up in libgcc.a. Or, you can put it in a linkonce section if the port supports it, and always emit them in each unit, or, after you discover what longcall is, you might want to do it as private in each unit. I might recommend the last alternative.