[llvm-dev] Redefining optnone to help LTO

Robinson, Paul via llvm-dev
Tue, 17 Jan 2017 02:07:58 -0000

> -----Original Message-----
> From: Philip Reames [mailto:listmail at philipreames.com]
> Sent: Friday, January 13, 2017 9:43 PM
> To: Robinson, Paul; llvm-dev at lists.llvm.org
> Subject: Re: [llvm-dev] Redefining optnone to help LTO
>
> I would prefer we introduce a new attribute for this purpose.  I
> regularly use optnone for debugging/reduction purposes or when trying to
> understand the interaction of our pass pipeline.  Having an attribute
> that tells the optimizer to ignore a function (more or less) is really
> useful, and I'd rather not loose that functionality.
>
> Philip

Hi Philip,
I might have incorrectly given the impression that the attribute would
become something used _only_ for LTO.  That isn't the intent at all.
In *addition* to all the ways you can set 'optnone' now, it would *also*
be set on more-or-less all functions at -O0.  Then the optimization
passes (whether they run immediately in a normal compilation, or later
in an LTO compilation) would continue to notice the attribute and do the
usual thing.  At -O0 in normal compilation, the attribute would have no
practical effect because no pass that looks for 'optnone' would actually
run in the first place; that is, for -O0 in a normal compilation, adding
'optnone' to everything is really a no-op.

The "more-or-less" qualification comes up because optnone is not
allowed
in combination with certain other attributes.  Don't want to be creating
invalid IR, after all!  But that's the only exceptional case.

Does that help?
--paulr