473,563 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ommiting frame pointer

Hello -

I have been told that for extra efficiency we should always compile
code with frame pointer ommited (-fomit-frame-pointer), also -pipe.

What is the reason for this? Why does it make a better executable? Are
there situations where it doesn't work or isn't the best thing to do?

Also I don't understand why not always make Position Independent Code
(-fPIC)?

Thanks.

Dec 12 '07 #1
14 1838
In article <sl************ *******@nospam. invalid>,
Brian <tr**@nospam.co mwrote:
>I have been told that for extra efficiency we should always compile
code with frame pointer ommited (-fomit-frame-pointer)
Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors). Using one can make debugging easier,
though I think gdb can do most things without one.
also -pipe.
This gcc option just uses pipes between compiler stages instead of
temporary files. It might speed up compilation a little but probably
not a lot on current systems.
>Also I don't understand why not always make Position Independent Code
(-fPIC)?
Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.

You may get more detailed or accurate answers in a gcc-specific group.

-- Richard
--
:wq
Dec 13 '07 #2
Brian <tr**@nospam.co mwrites:
I have been told that for extra efficiency we should always compile
code with frame pointer ommited (-fomit-frame-pointer), also -pipe.

What is the reason for this? Why does it make a better executable? Are
there situations where it doesn't work or isn't the best thing to do?

Also I don't understand why not always make Position Independent Code
(-fPIC)?
comp.unix.progr ammer or gnu.gcc.help would be better places to
ask these questions, because they deal with matters that are not
defined by standard C.
--
Ben Pfaff
http://benpfaff.org
Dec 13 '07 #3
Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors).
I haven't seen any influence on modern x86 CPU's anymore. The number
of registers
does simply not matter with the gcc code generator at the moment (even
amd64
has no significant performance improvement).
Also I don't understand why not always make Position Independent Code
(-fPIC)?

Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.
Only on x86. amd64 has Instruction pointer relative operations so
there is
no extra indirection.
Dec 13 '07 #4
llothar wrote:
>Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors).

I haven't seen any influence on modern x86 CPU's anymore. The number
of registers
does simply not matter with the gcc code generator at the moment (even
amd64
has no significant performance improvement).
It may not with gcc, but other compilers do gain when omitting the frame
pointer on AMD64.

--
Ian Collins.
Dec 13 '07 #5
Op Thu, 13 Dec 2007 10:38:22 +0100 schreef llothar <ll*****@web.de >:
>Also I don't understand why not always make Position Independent Code
(-fPIC)?

Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.
For the x86-family,
Only on x86. amd64 has Instruction pointer relative operations so
there is no extra indirection.
There are dozens more architectures than x86 and amd64.

--
Gemaakt met Opera's revolutionaire e-mailprogramma:
http://www.opera.com/mail/
Dec 13 '07 #6
"llothar" <ll*****@web.de wrote in message
news:8e******** *************** ***********@i12 g2000prf.google groups.com...
>Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors).

I haven't seen any influence on modern x86 CPU's anymore. The
number of registers does simply not matter with the gcc code
generator at the moment (even amd64 has no significant
performance improvement).
I've seen programs where the extra register(s) made a measurable (sometimes
huge) difference and others where it had no effect at all. It all depends
on the particular code being compiled, other optimizations enabled, etc.
>Also I don't understand why not always make Position Independent
Code (-fPIC)?

Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.

Only on x86. amd64 has Instruction pointer relative operations so
there is no extra indirection.
I've read that some architectures have no performance penalty for PIC, but
x86 and amd64 definitely do not fall in that group. Amd64's RIP-relative
addressing reduces the penalty but does not eliminate it.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

Dec 13 '07 #7
>>I have been told that for extra efficiency we should always compile
>>code with frame pointer ommited (-fomit-frame-pointer)

Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors). Using one can make debugging easier,
though I think gdb can do most things without one.
Wouldn't it be better then if the frame pointer was ommited by default
unless debugging (-g) is switched on?
>also -pipe.

This gcc option just uses pipes between compiler stages instead of
temporary files. It might speed up compilation a little but probably
not a lot on current systems.
So why isn't this enabled by default?
>>Also I don't understand why not always make Position Independent Code
(-fPIC)?

Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.
Isn't it good to be able to relocate all code, not just library code?

Best

Brian

Dec 14 '07 #8
In article <sl************ *******@nospam. invalid>,
Brian <tr**@nospam.co mwrote:
>Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.
>Isn't it good to be able to relocate all code, not just library code?
Why? Who needs to relocate code in complete programs?

The code in compiled-but-not-linked files (.o files in unix) is
relocatable in the sense that it doesn't yet have the addresses filled
in, but that's a quite separate issue: when it's linked, a new version
is made with the addresses filled in. The code in shared libraries
needs to be runnable at different addresses without copying it (so it
can be shared).

-- Richard
--
:wq
Dec 14 '07 #9
"Brian" <tr**@nospam.co mwrote in message
news:sl******** ***********@nos pam.invalid...
>>>I have been told that for extra efficiency we should always compile
code with frame pointer ommited (-fomit-frame-pointer)

Not using a frame pointer makes an extra register available for other
uses, which speeds things up on processors with few registers (in
particular, on x86 processors). Using one can make debugging easier,
though I think gdb can do most things without one.

Wouldn't it be better then if the frame pointer was ommited by default
unless debugging (-g) is switched on?
Some debugging can be done without symbols, and it's easier with a frame
pointer.
>>also -pipe.

This gcc option just uses pipes between compiler stages instead of
temporary files. It might speed up compilation a little but probably
not a lot on current systems.

So why isn't this enabled by default?
Because a pipe means multiple compiler stages would be in memory and
consuming CPU at the same time. That may be fine for some systems, but it
isn't for others.
>>>Also I don't understand why not always make Position Independent Code
(-fPIC)?

Position independent code is likely to be somewhat slower on most
systems, just because of extra indirections. It's needed for shared
libraries.

Isn't it good to be able to relocate all code, not just library code?
Non-library code is relocated at link time; it doesn't need to be
position-independent (or relocated) at runtime.

S

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

Dec 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1627
by: Phil | last post by:
Supposedly, the code below should assign the correct value to the 'url' variable. But all I get is a blank 'main' Frame with apparently nowhere to go when I click on the link in the 'menu' Frame.. Worst(yesyes!!) 1 - Explorer 6 : clicking a link in the 'menu' frame simple reopens an instance of the FRAMESET, syntax error msg. 2 - Netscape...
5
1781
by: Tim Streater | last post by:
I have this arrangement of frames: <html><head><script type="text/javascript"></script></head> <frameset rows="100,*"> <frameset cols="135,*,165"> <frame name="logo" src="some.html" scrolling="No"> <frame name="title" src="someother.html" scrolling="No"> <frame name="nav" src="yetmore.html" scrolling="No"> </frameset>
3
3332
by: asm | last post by:
Hello all, I need your help on this problem. I wrote a little program as follows. (BTW, I worked on a new dell latitude, runing Linux kernel 2.4.19, i686). Program was compiled with gcc 3.2 void foo() { char t; strcpy(t, "012345678901234567890123456789012345678");
4
3609
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
0
1192
by: Søren M. Olesen | last post by:
How do I manipulate a control in one frame from another frame ?? I've tried something like: Class1 TextBox.Text="Text1" Session("TextBox")=TextBox1 Class2
4
4171
by: AndrewV | last post by:
I have an html page that has 2 frames ("input" and "result"). In the "input" frame, there is a text box and a button. User enters an id in the text box, then click on the button. In the click event, I would like to call an asp.net page, and passing in the text box value as a query string parameter (http://mysite/mypage.aspx?id=x) and display...
5
3498
by: Martin Chen | last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main frame. The contents frame has a menu bar written with with javascript (in the context of a table). In IE6.1 everything works fine as it also does in firefox if I call the contents frame directly (i.e. outside of its frameset). However, if I call my main page...
2
2120
by: bekz | last post by:
Hi All, I have written exploits for binaries with fixed stack frame pointer. But now a days most of the compliers generates instrutions with random stack frame pointer. And with injecting Windows API function addresses, how can we inject the argument address for foreign exe? How can I go about writing exploits for such codes? Note:...
4
14798
by: code break | last post by:
Hi all, What is the difference between stack pointer and frame pointer ? Any suggestions are welcome ,,,
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.