Clangs equivalent to GCCs -Og flag?

GCC has a debug level flag of -Og which enables all optimizers that won’t degrade the debugging experience greatly.

Does clang have an equivalent?

Thanks in advance.

Dan

GCC has a debug level flag of -Og which enables all optimizers that won’t degrade the debugging experience greatly.

Does clang have an equivalent?

No, clang had no equivalent at this time.

Thanks,

    Perhaps there might be some documentation somewhere that would give me
an idea of which optimizations to enable individually?

Not really - optimized debug info is still pretty lacking in Clang. Even
the most common/basic optimizations (SROA, for example) are going to pretty
heavily impact debuggability today.

- Dave

People ask about this from time to time, but we’ve never done anything about it.

One thing I noticed about GCC –Og is that it’s 99% identical to their –O1. I’d be curious about people’s experience using Clang –O1 –g and whether that experience is somewhere close to reasonable.

–paulr

People ask about this from time to time, but we’ve never done anything about it.

One thing I noticed about GCC –Og is that it’s 99% identical to their –O1. I’d be curious about people’s experience using Clang –O1 –g and whether that experience is somewhere close to reasonable.

It’s still likely to be not great for debugging - mostly because it still runs SROA which promotes allocas into registers and out variable liveness/tracking falls down quickly there.

Chandlers repeatedly suggested that we fix debug info to the point that -O1 is highly debuggable (might involve changing -O1 too, if there are fundamentally destructive things in there that hurt debugging) and then make that the default (because its often as fast or faster than compiling at -O1 anyway, which is what people usually care about - compile time and simplicity/understandability)

People ask about this from time to time, but we've never done anything
about it.

One thing I noticed about GCC –Og is that it's 99% identical to their –O1.

Not really. The optimization level is set to 1, but the pass pipeline setup
is very different between O1 and Og.

David

I remember using gcc’s “tell me what optimizations you ran” flag, which does something like print out the list of –f switches you would need to use to get the same effect as the optimization flags you actually provided. Comparing –O1 to –Og I saw only one difference. Hence my statement that gcc’s –O1 and –Og are 99% equivalent. It is a very black-box experiment but I think it’s indicative. Or at least instructive.

–paulr

-fdump-passes? The dump result can be misleading. For instance, the post ipa optimization is grouped under *all_optimization or *all_optimization_g groups. With -Og, *all_optimization is off, but all the nested optimizations that are turned on normally under opt level 1 is still marked as ‘ON’ – that is why you don’t see many difference. The optimizations included in *all_optimization_g group is a much smaller set.

The early optimization pipelines are very similar. WIth -Og, early SRA pass is disabled.

David