Zulip Chat Archive

Stream: lean4

Topic: When to [always_inline]?


François G. Dorais (Jan 08 2023 at 09:53):

I've been trying to figure out the difference between [inline] and [always_inline] but didn't find anything super useful. I'm especially puzzled by the fact that they are often used together!?

Mario Carneiro (Jan 08 2023 at 10:02):

this is a workaround for the fact that there are two lean compilers

Henrik Böving (Jan 08 2023 at 10:02):

I cannot speak for the old code generator, in the new code generator there is afaik no difference between the two right now but there is a TODO to limit the inlining of inline tagged declarations to a certain quota in the future. always_inline on the other hand does as you would expect force the new code generator to always perform inlining.

Henrik Böving (Jan 08 2023 at 10:03):

The old code generator does not seem to react to always_inline so that is the reason you are seeing declarations with both inline and always_inline.

Mario Carneiro (Jan 08 2023 at 10:03):

the old code generator does not recognize the [always_inline] attribute, while the new one needs it

François G. Dorais (Jan 08 2023 at 10:21):

That is enlightening! To summarize: [inline] is fine unless you realize you also need to [always_inline] when using the new code generator?

François G. Dorais (Jan 08 2023 at 10:23):

Aside: does abbrev always inline?

Mario Carneiro (Jan 08 2023 at 10:23):

I believe so

Mario Carneiro (Jan 08 2023 at 10:23):

it's marked as @[inline] (not @[always_inline]) automatically

François G. Dorais (Jan 08 2023 at 10:25):

So @[always_inline] abbrev ... could make sense?

Mario Carneiro (Jan 08 2023 at 10:25):

I think so

Mario Carneiro (Jan 08 2023 at 10:25):

@[always_inline] is normally only used on instances

François G. Dorais (Jan 08 2023 at 10:25):

Thanks! This was very helpful!


Last updated: Dec 20 2023 at 11:08 UTC