[Issue 10848] Compiler should always try to inlining a direct lambda call

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 20 05:53:30 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10848



--- Comment #6 from Manu <turkeyman at gmail.com> 2013-08-20 05:53:27 PDT ---
(In reply to comment #4)
> (In reply to comment #1)
> > Sounds like a good case for a __forceinline attribute, and then apply it
> > implicitly in this case. This situation could leverage the same internal
> > mechanic.
> 
> "forceinline" is misleading word.
> 
> This proposal *does not* guarantee that the generated code is always inlined.
> If the given lambda body is too large/complex, or compiler's inlining ability
> is very little, the generated code may not be inlined. The language spec should
> allow it.

Can you give an example of where the compiler is unable to inline code?
I don't see why any single function with the source available shouldn't
technically be inlinable. If you're writing a function that's more like a macro
(but not a mixin, ie, shouldn't pollute/interfere with containing scope), it
may be useful... but yes, sure it's generally true that when code gets too
large, there becomes very few compelling reasons to inline.

> > I still have MANY places where I want to guarantee inlining of certain
> > functions.
> 
> Inlining would increase compilation time. Such places should be defined
> carefully.

It not really a matter of care, I use it where it's a requirement.

That's why I'd suggest the keyword should be '*force*inline'; this suggests the
programmer deliberately made the request, and knows exactly what they're doing.
It's not an attribute that makes any guarantees about performance, and
shouldn't be considered an optimisation. It's about fine control in terms of
code generation.

I thought this was an interesting parallel. In the case you present here, or in
cases where you may have an algorithm that iterates a loop block implemented as
a lambda in some particular way, I can't imagine a situation where you would
ever want that lambda to not inline. But there are also many low level function
I need to explicitly mark too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list