[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 12:50:56 PST 2017

probinson added a comment.

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

> In https://reviews.llvm.org/D28404#640046, @probinson wrote:
> > "I don't care" doesn't seem like much of a principle.
> Long version is: "There is no use-case, no users, so I don't have much motivation to push it forward for the only sake of completeness". Does it sound enough of a principle like that?

No.  You still need to have adequate justification for your use case, which I think you do not.

>> 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.
> Having to modifying the source isn't friendly. Not being able to honor -O0 during LTO is not user-friendly.

IMO, '-O0' and '-flto' are conflicting options and therefore not deserving of special support.

In my experience, modifying source is by far simpler than hacking a build system to make a special case for compiler options for one module in an application.  (If you have a way to build Clang with everything done LTO except one module built with -O0, on Linux with ninja, I would be very curious to hear how you do that.)  But if your build system makes that easy, you can just as easily remove `-flto` as add `-O0` and thus get the result you want without trying to pass conflicting options to the compiler.  Or spending time implementing this patch.

>>   I don't think `-c -O0` should get this not-entirely-O0-like behavior.
> What is "not-entirely"? And why do you think that?

"Not entirely" means that running the -O0 pipeline, and running an optimization pipeline but asking some subset of passes to turn themselves off, does not get you the same result.  And I think that because I'm the one who put 'optnone' upstream in the first place.  The case that particularly sticks in my memory is the register allocator, but I believe there are passes at every stage that do not turn themselves off for optnone.


More information about the cfe-commits mailing list