I have read the gcc
documentation for optimization options. They do not have examples.
One tedious method is to use godbolt and try so many options and see which option works for a specific optimization flag.
I have written the following trivial code:
#include <cmath>
double calculate(double x)
{
int y=x+sin(x);
return exp(x)+exp(-x);
}
int main(int argc,char *argv[])
{
return ceil(calculate(argc));
}
and I compiled it with
g++ -Q -v -O3 main.cpp
which prints all enabled optimization flag for me and not the used option flags. I also need to know the optimization flags for a specific function excluding the optimizations used for the libraries.
How is it possible for me to get the list of optimization flags used for compilation of calculate
function?
现代版本的GCC具有-fverbose-asm
选项,可以转储在汇编文件中的注释中启用的优化选项,您可以通过使用-S
或-save-temps
进行编译
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.