English 中文(简体)
-fmit帧指针*总是*省略fp吗?
原标题:Does -fomit-frame-pointer *always* omit the fp?

-fomit帧指针是否总是省略帧指针?是否存在需要同时设置pc和fp的情况?动态堆栈增长是否会强制设置fp?专门询问MIPS32。谢谢

最佳回答

帧指针并不是正确执行所必需的,除非有时用于异常展开。动态堆栈增长通常需要某种帧指针,但它并不绑定到特定的寄存器,而是通过正常的数据流分析进行分配。

基本上,-fomit帧指针将FP从固定寄存器分配降级为伪寄存器,并使初始化受到死存储消除的影响。因此,第一个问题的答案是否定的,它并不总是省略它。

问题回答

不,通常不需要帧指针。编译器可以访问相对于堆栈指针的局部变量,并且不需要特殊的帧指针。

尽管如此,标准的帧指针设置序列在调试崩溃的程序时(即使不是用-g编译的)也会有所帮助,因为调试器可以使用帧指针信息来重建调用堆栈。在没有帧指针的情况下,它没有信息来确定一个堆栈帧从哪里开始,下一个帧从哪里结束。

因此,当使用-fomit帧指针时,您是在用性能换取更困难的调试,以防崩溃。如果代码的性能关键部分是小循环,并且不调用任何函数,那么省略帧指针也不会带来什么好处。

不是mips的人,而是应该应用于任何系统的东西:如果堆栈需要在任何点对齐,则需要使用一个帧来存储原始指针(因为堆栈地址和对齐可能不知道)





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签