[llvm-dev] [cfe-dev] RFC: Supported Optimizations attribute
John McCall via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 4 13:00:10 PST 2018
On 4 Dec 2018, at 15:36, Sanjoy Das wrote:
> On Tue, Dec 4, 2018 at 12:04 PM Arthur O'Dwyer
> <arthur.j.odwyer at gmail.com> wrote:
>> Peanut gallery says: I don't fully understand the use-case or the
>> domain, but this description sounds unworkable to me.
>>
>> AIUI, there are two players here: the "brittle optimization" (which
>> relies on some invariant), and the "transform" (which has the power
>> to break that invariant).
>>
>> The only two mathematically workable scenarios are:
>> (A) The brittle optimization's invariant is "impossible to [break]
>> for standard semantic/structural reasons." Therefore no transform
>> ever needs to know anything about it. The result is a "robust"
>> optimization, and no need for the supported-optimizations flagset.
>> (B) The brittle optimization's invariant is, in fact, brittle. Any
>> transform that doesn't explicitly preserve the invariant can and will
>> break the invariant. Therefore, every transform must have its own
>> whitelist of "invariants I know I don't break." Any flag in the
>> supported-optimizations flagset which is not whitelisted by a given
>> transform must be cleared when that transform is applied to the code.
>> (Because, by definition, a transform that doesn't explicitly preserve
>> the brittle invariant must be assumed to break it.)
>
> I think the overarching idea here is that good faith opts will only
> rely on invariants that can only be broken by inter-procedural
> optimizations. So intra-procedural opts should not need any changes.
>
> In a sense this proposal makes function call edges semantically
> special; functions calls are no longer yet another kind of control
> flow, but they can act as bridges between LLVM IR with different
> semantics. Collapsing a function call edge is now a semantically
> interesting operation.
Note that this has always been true in some ways. For example, naively
cloning call sites during inlining can change exception semantics; to
make this work correctly you have to reconcile the EH contexts of the
inner and outer calls, which is not always possible if the personalities
differ. Or to pick an even grosser example, you can't just clone a call
to `llvm.returnaddress` during inlining.
Note also that IPO between functions with the same set of supported
optimizations also doesn't involve any change in semantics.
John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181204/b27eb838/attachment.html>
More information about the llvm-dev
mailing list