[PATCH] D28404: IRGen: Add optnone attribute on function during O0

Paul Robinson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 11:41:46 PST 2017


probinson added a comment.

In https://reviews.llvm.org/D28404#639887, @mehdi_amini wrote:

> In https://reviews.llvm.org/D28404#639874, @probinson wrote:
>
> > Over the weekend I had a thought:  Why is -O0 so special here?  That is, after going to all this trouble to propagate -O0 to LTO, how does this generalize to propagating -O1 or any other specific -O option?  (Maybe this question would be better dealt with on the dev list...)
>
>
> O0 is "special" like Os and Oz because we have an attribute for it and passes "know" how to handle this attribute.
>  I guess no-one cares enough about https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//O3 to find a solution for these (in the context of LTO, I don't really care about https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2/).
>  It is likely that Og would need a special treatment at some point, maybe with a new attribute as well, to inhibit optimization that can't preserve debug info properly.


"I don't care" doesn't seem like much of a principle.

Optnone does not equal -O0.  It is a debugging aid for the programmer, because debugging optimized code sucks.  If you have an LTO-built application and want to de-optimize parts of it to aid with debugging, then you can use the pragma, as originally intended.  I don't think `-c -O0 -flto` should get this not-entirely-O0-like behavior.


https://reviews.llvm.org/D28404





More information about the cfe-commits mailing list