What does 'inline' mean?

Manu turkeyman at gmail.com
Fri Jun 12 01:51:48 UTC 2020


On Fri, Jun 12, 2020 at 8:20 AM Walter Bright via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On 6/11/2020 8:42 AM, kinke wrote:
> > My interest in this wasn't triggered by wanting to enforce particular
> functions
> > to be emitted into each referencing CU, but by
> > a) the current emission scheme requiring LTO in order to inline suited
> little
> > templated functions when compiling static libs in one go,
> > b) being able to use linkonce_odr instead of weak_odr linkage for
> template
> > stuff, meaning potentially less work for the linker, and potentially
> quite a bit
> > less work for the optimizer. Compiling an optimized dub (a single object
> file)
> > with LDC using -linkonce-templates reduces the total compile+optimize
> times by
> > roughly 25%, simply because LLVM inlines most little template stuff and
> can then
> > discard the unused linkonce_odr functions early in the process, without
> > uselessly optimizing them to death (as it currently cannot discard it,
> as other
> > libraries/objects might depend on some template instances as mentioned
> earlier).
>
> A library consists of two parts:
>
> 1. the "header" file
> 2. the binary to link with, which may be absent
>
> Take some care in what goes in 1, what goes in 2, and you'll be fine.
>
> For example, consider core.checkedint. The functions in it are all
> templates so
> that they can be used with -betterC which doesn't link with druntime. It's
> a
> classic "header only" library. It works fine.
>

We're not talking about templates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20200612/96ddb3af/attachment-0001.htm>


More information about the Digitalmars-d mailing list