1

我对 GCC 还是很陌生,我想知道我究竟如何使用某些分析开关。

我已经阅读了-ftree-loop-ivcanonand的 GCC 手册条目-fivopts(两者都没有暗示-fprofiled-generate/use),虽然我对它们的作用有一个(相对)好主意,但我不知道我应该在哪里使用它们,或者我是否应该使用它们.

我应该在组合编译中使用标志吗?

g++ Example.cxx -o Example.exe -Wall -ftree-loop-ivcanon -fivopts

只有汇编?

g++ Example.cxx -o Example.o -c -Wall -ftree-loop-ivcanon -fivopts

还是只有链接?

g++ Example.o -o Example.exe -Wall -ftree-loop-ivcanon -fivopts

我应该只在启用分析时使用这些标志,还是可以将它们与 -On 一起使用?

最后,如果我在分析时确实使用了这些,我应该将它们与生成开关或使用开关一起使用,还是两者都使用?

4

2 回答 2

1

据我所知,您只能在编译时使用这些。

于 2012-07-20T04:22:09.543 回答
0

-ftree-loop-ivcanon and -fivopts only affect compilation, not linking, but I'm pretty sure they don't do anything unless you enable optimisation, with at least -O.

You probably don't need to use them, just use -O or -O2 or -O3 instead of tweaking individual or more-specific options, unless you know exactly what you're trying to achieve and are measuring the precise effects.

If you're trying to use profile-guided optimisation then you definitely want to use -O or a higher optimisation level - it's a complete waste of time optimising based on profile data if you're not even enabling basic optimisations such as inlining and constant propagation.

于 2012-07-20T11:44:52.010 回答