下面列出它的说明:
-O
-O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a
large function.
With -O, the compiler tries to reduce code size and execution time, without performing any
optimizations that take a great deal of compilation time.
-O turns on the following optimization flags: -fdefer-pop -fdelayed-branch
-fguess-branch-probability -fcprop-registers -floop-optimize -fif-conversion -fif-conver-
sion2 -ftree-ccp -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-ter -ftree-lrs
-ftree-sra -ftree-copyrename -ftree-fre -ftree-ch -funit-at-a-time -fmerge-constants
优化编译的参数是:-O[注意,是大写字母O,来自英文 Optimize]
-O1 [优化1,正常优化]
-O2 [优化2,优化程度高一级]
-O3 [优化3,优化程度最高]
不优化是 -O0
详细情况用:
man gcc
阅读 "OPTIMIZATION OPTIONS" 那部分
环境:Ubuntu18.04, gcc 7.5
开O2优化,不会断言,输出结果:
不开优化,输出结果:
开O2优化,死循环
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)