Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5703

Re: efficient function call

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!news.uni-stuttgart.de!news.nask.pl!news.nask.org.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From Edek <edek.pieITAKNIECZYTAM@gmail.com>
Newsgroups comp.lang.c++
Subject Re: efficient function call
Date Fri, 27 May 2011 16:39:05 +0200
Organization ATMAN - ATM S.A.
Lines 65
Message-ID <4DDFB789.2080107@gmail.com> (permalink)
References <b77d43d1-0865-4c3d-9179-6cda0ff992c1@m40g2000vbt.googlegroups.com> <5b9040f8-e35b-4cb0-95c8-1b89838f1da9@s14g2000vbi.googlegroups.com> <irim81$v8d$1@dont-email.me> <579f855a-ff3b-4e65-a977-9773fb58a07c@e35g2000yqc.googlegroups.com> <irleec$po3$1@dont-email.me> <irllnn$hdq$1@node2.news.atman.pl> <slrnitvaoc.gtj.grahn+nntp@frailea.sa.invalid>
NNTP-Posting-Host 81.219.115.2
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace node2.news.atman.pl 1306506837 6501 81.219.115.2 (27 May 2011 14:33:57 GMT)
X-Complaints-To usenet@atman.pl
NNTP-Posting-Date Fri, 27 May 2011 14:33:57 +0000 (UTC)
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Linux/3.1.0-15 Thunderbird/3.1.0
To Jorgen Grahn <grahn+nntp@snipabacken.se>
In-Reply-To <slrnitvaoc.gtj.grahn+nntp@frailea.sa.invalid>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:5703

Show key headers only | View raw


> So you're saying a file
>
>    static int foo() { return 42; }
>    int bar() { return 69+foo(); }
>
> will never inline foo() if I use g++ with the -fpic option?
> That sounds wrong -- and I cannot repeat it on my system.
>
> tuva:/tmp>  g++ -W -Wall -ansi -fpic -O3 -c foo.cc
> tuva:/tmp>  nm -C foo.o
> 00000000 V DW.ref.__gxx_personality_v0
> 00000000 T bar()
>           U __gxx_personality_v0
>

To check that I am not lying to you:
------------------------------------------------------
int answer () { return 42; };

int bar () { return 69|answer(); }
-------------------------------------------------
gcc -O3 -S test.cpp

	.type	_Z3barv, @function
_Z3barv:
.LFB1:
	.cfi_startproc
	movl	$111, %eax
	ret
------------------------------------------------------
gcc -O3 -S -fPIC test.cpp

	.type	_Z3barv, @function
_Z3barv:
.LFB1:
	.cfi_startproc
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	_Z6answerv@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	orl	$69, %eax
	ret

And the working thing:
-------------------------------------------------------------------------
  [devel@marvin preload]$ LD_LIBRARY_PATH=. ./main
bar gives111
  [devel@marvin preload]$ LD_LIBRARY_PATH=. LD_PRELOAD=./mylib.so ./main
bar gives1093
  [devel@marvin preload]$
----------------------------------------------------------------------

where main is

#include <iostream>

extern int bar();

int main () {
     std::cout << "bar gives" << bar () <<std::endl;
}

Edek

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

efficient function call hamze <hamze60@gmail.com> - 2011-05-24 05:52 -0700
  Re: efficient function call Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 09:52 -0400
    Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-24 18:28 +0000
    Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-24 11:49 -0700
      Re: efficient function call Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-24 15:07 -0400
        Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:37 -0700
          Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-25 10:38 +0000
            Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 11:08 -0700
              Re: efficient function call Dombo <dombo@disposable.invalid> - 2011-05-25 21:38 +0200
              Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-26 11:44 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-26 15:53 +0200
                Re: efficient function call yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-05-27 08:31 +0000
                Re: efficient function call Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 13:45 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-27 16:17 +0200
                Re: efficient function call Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 22:38 +0000
                Re: efficient function call Edek <edek.pieITAKNIECZYTAM@gmail.com> - 2011-05-27 16:39 +0200
      Re: efficient function call Joshua Maurice <joshuamaurice@gmail.com> - 2011-05-24 14:30 -0700
        Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:39 -0700
      Re: efficient function call hamze <hamze60@gmail.com> - 2011-05-25 00:20 -0700

csiph-web