Official GCC documentation doesn't give a list of optimisations enabled for C++ at the -Og
level stating only that selected options would not harm debuggability.
I need to know the list of optimisations, do perform a binary search which particular one cause a bug in the inlined template class constructor call on the ARM Cortex-M7 (arm-none-eabi) platform. I'd like to disable only the one that prevents our code from working correctly. Is there a list somewhere or an option to ask GCC itself?
Plus that would help to me check if I really see the bug in the compiler, or there is other problem revealed by the optimisations applied in that place. In the former case I need to nail it by minimal working example, and that's not the easy case. The code with -O0
works fine.
You can always see what an optimization level enables by doing: g++ -c -Q -Og --help=optimizers | grep enabled
. From the man page:
If the
-Q
option appears on the command line before the--help=
option, then the descriptive text displayed by--help=
is changed. Instead of describing the displayed options, an indication is given as to whether the option is enabled, disabled or set to a specific value (assuming that the compiler knows this at the point where the--help=
option is used).
This outputs on GCC 6.1.1 x86_64:
-faggressive-loop-optimizations [enabled]
-fasynchronous-unwind-tables [enabled]
-fauto-inc-dec [enabled]
-fcombine-stack-adjustments [enabled]
-fcompare-elim [enabled]
-fcprop-registers [enabled]
-fdce [enabled]
-fdefer-pop [enabled]
-fdelete-null-pointer-checks [enabled]
-fdse [enabled]
-fearly-inlining [enabled]
-fforward-propagate [enabled]
-ffunction-cse [enabled]
-fgcse-lm [enabled]
-fguess-branch-probability [enabled]
-finline [enabled]
-finline-atomics [enabled]
-fipa-profile [enabled]
-fipa-pure-const [enabled]
-fipa-reference [enabled]
-fira-hoist-pressure [enabled]
-fira-share-save-slots [enabled]
-fira-share-spill-slots [enabled]
-fivopts [enabled]
-fjump-tables [enabled]
-flifetime-dse [enabled]
-fmath-errno [enabled]
-fpeephole [enabled]
-fplt [enabled]
-fprefetch-loop-arrays [enabled]
-frename-registers [enabled]
-freorder-blocks [enabled]
-frtti [enabled]
-fsched-critical-path-heuristic [enabled]
-fsched-dep-count-heuristic [enabled]
-fsched-group-heuristic [enabled]
-fsched-interblock [enabled]
-fsched-last-insn-heuristic [enabled]
-fsched-rank-heuristic [enabled]
-fsched-spec [enabled]
-fsched-spec-insn-heuristic [enabled]
-fsched-stalled-insns-dep [enabled]
-fschedule-fusion [enabled]
-fshort-enums [enabled]
-fshrink-wrap [enabled]
-fsigned-zeros [enabled]
-fsplit-ivs-in-unroller [enabled]
-fsplit-wide-types [enabled]
-fssa-backprop [enabled]
-fstdarg-opt [enabled]
-fstrict-volatile-bitfields [enabled]
-fno-threadsafe-statics [enabled]
-ftrapping-math [enabled]
-ftree-builtin-call-dce [enabled]
-ftree-ccp [enabled]
-ftree-ch [enabled]
-ftree-coalesce-vars [enabled]
-ftree-copy-prop [enabled]
-ftree-cselim [enabled]
-ftree-dce [enabled]
-ftree-dominator-opts [enabled]
-ftree-dse [enabled]
-ftree-forwprop [enabled]
-ftree-fre [enabled]
-ftree-loop-if-convert [enabled]
-ftree-loop-im [enabled]
-ftree-loop-ivcanon [enabled]
-ftree-loop-optimize [enabled]
-ftree-phiprop [enabled]
-ftree-reassoc [enabled]
-ftree-scev-cprop [enabled]
-ftree-sink [enabled]
-ftree-slsr [enabled]
-ftree-ter [enabled]
-fvar-tracking [enabled]
-fvar-tracking-assignments [enabled]
-fweb [enabled]