试图了解GCC选项-fomit帧指针 [英] Trying to understand gcc option -fomit-frame-pointer

查看:102
本文介绍了试图了解GCC选项-fomit帧指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求谷歌给我的 GCC 选项 -fomit-frame-pointer的的含义,会被重定向我下面的语句。

I asked google to give me the meaning of the gcc option -fomit-frame-pointer, which redirects me to the below statement.


-fomit-frame-pointer
        Don't keep the frame pointer in a register for functions that don't 
need one. This avoids the instructions to save, set up and restore frame 
pointers; it also makes an extra register available in many functions. It 
also makes debugging impossible on some machines.

按我为每个功能的知识,一个激活的记录将在此过程中存储器保持所有的局部变量和一些更多的信息的堆栈创建。我希望这个帧指针指函数的活动记录的地址。

As per my knowledge for each function, an activation record will be created in stack of the process memory to keep all local variables and some more information. I hope this frame pointer means the address of the activation record of a function.

在这种情况下,是什么功能的类型,它并不需要保持帧指针寄存器?如果我得到这个消息,我会尝试设计的基础上,新的功能(如果可能)。因为如果帧指针没有保存在寄存器某些指令将二进制被省略。这将真正noticably提高了一个应用程序,其中的功能数量较多的服务表现。

In this case what are the type of functions, for which it doesn't need to keep frame pointer in register? If i get this information, I will try to design the new function based on that(if possible). Because if frame pointer is not kept in registers some instructions will be omitted in binary. This will really improves the performace noticably in an application where number of functions are more.

推荐答案

大多数小型职能不需要帧指针 - 更大的功能可能需要一个。

Most smaller functions don't need a frame-pointer - larger functions MAY need one.

这的的确确是编译器如何很好地管理跟踪堆栈的使用方式,和那里的东西是在栈上(局部变量,传递给当前功能的参数和参数是ppared一个函数$ P $即将被称为)。我不认为这是容易表征需要或不需要帧指针的函数[技术上,NO功能必须有一个帧指针 - 它更的如果编译器认为有必要降低它的情况下其他code的复杂性。

It's really about how well the compiler manages to track how the stack is used, and where things are on the stack (local variables, arguments passed to the current function and arguments being prepared for a function about to be called). I don't think it's easy to characterize the functions that need or don't need a frame-pointer [technically, NO function HAS to have a frame-pointer - it's more a case of "if the compiler deems it necessary to reduce the complexity of other code"].

我不认为你应该试图使功能没有帧指针作为自己的战略编码的一部分 - 就像我说的,简单的功能不需要它们,所以使用-fomit帧指针,你会得到的寄存器分配提供多一个寄存器,并在入境/出境1-3指令保存功能。如果你的函数需要帧指针,这是因为编译器决定比使用帧指针是更好的选择。这不是有没有的功能帧指针一个目标,这是有code这两个正确和快速的工作目标。

I don't think you should "attempt to make functions not have frame-pointer" as part of your strategy for coding - like I said, simple functions don't need them, so use -fomit-frame-pointer, and you'll get one more register available for the register allocator, and save 1-3 instructions on entry/exit to functions. If your function needs a frame-pointer, it's because the compiler decides that's a better option than using frame pointer. It's not a goal to have functions without frame pointer, it's a goal to have code that works both correctly and fast.

请注意,没有framepointer应该提供更好的性能,但它不是一些灵丹妙药,让巨大的改进 - 尤其是不X86-64,已经有16个寄存器开始。在32位86,因为它只有8个寄存器,其中之一是stackpointer,并且占用了另一作为帧指针装置的寄存器空间的25%被取。要更改至12.5%,是相当的改善。当然,编译64位将帮助了很多了。

Note that "not having framepointer" should give better performance, but it's not some magic bullet that gives enormous improvements - particularly not on x86-64, which already has 16 registers to start with. On 32-bit x86, since it only has 8 registers, one of which is stackpointer, and taking up another as the frame-pointer means 25% of register-space is taken. To change that to 12.5% is quite an improvement. Of course, compiling for 64-bit will help quite a lot too.

这篇关于试图了解GCC选项-fomit帧指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆