www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - LDC cross-module-inlining

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Is cross-module-inlining enabled by default in LDC when compiling 
in release mode or do I have to use explicitly flag for it? I 
can't find any such flag from the output of neither

     ldc2 -h

nor

     ldmd2 -h

.

Johan Engelen mentioned this, then experimental, flag in his 
DConf talk from 2017 [1]

[1] https://www.youtube.com/watch?v=IZY67TBZ0V4
Aug 09 2020
next sibling parent reply claptrap <clap trap.com> writes:
On Sunday, 9 August 2020 at 22:18:13 UTC, Per Nordlöw wrote:
 Is cross-module-inlining enabled by default in LDC when 
 compiling in release mode or do I have to use explicitly flag 
 for it? I can't find any such flag from the output of neither

     ldc2 -h

 nor

     ldmd2 -h

 .

 Johan Engelen mentioned this, then experimental, flag in his 
 DConf talk from 2017 [1]

 [1] https://www.youtube.com/watch?v=IZY67TBZ0V4
If you enable link time optimisation you get cross module inlining, -flto=full I'm not 100% sure but I think LDC did cross module inlining by default at some point, then I updated the compiler and had to add the LTO thing. I think there is an option to enable just cross module inlining, but if you want speed you'll probably want to have LTO enabled anyway?
Aug 09 2020
next sibling parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Sunday, 9 August 2020 at 22:45:16 UTC, claptrap wrote:
 I'm not 100% sure but I think LDC did cross module inlining by 
 default at some point, then I updated the compiler and had to 
 add the LTO thing. I think there is an option to enable just 
 cross module inlining, but if you want speed you'll probably 
 want to have LTO enabled anyway?
Yes, I do. Thanks.
Aug 09 2020
prev sibling parent reply Daniel Kozak <kozzi11 gmail.com> writes:
On Mon, Aug 10, 2020 at 12:50 AM claptrap via Digitalmars-d-learn <
digitalmars-d-learn puremagic.com> wrote:

 On Sunday, 9 August 2020 at 22:18:13 UTC, Per Nordl=C3=B6w wrote:
 ...
If you enable link time optimisation you get cross module inlining, -flto=3Dfull I'm not 100% sure but I think LDC did cross module inlining by default at some point, then I updated the compiler and had to add the LTO thing. I think there is an option to enable just cross module inlining, but if you want speed you'll probably want to have LTO enabled anyway?
I am not sure but last time I checked ldc does not do cross module inlinig by default, and LTO only help if your ldc(druntime+phobos) are built with enabled LTO[1] [1] https://github.com/ldc-developers/ldc/issues/2182#issuecomment-34316663= 3
Aug 09 2020
parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote:
 I am not sure but last time I checked ldc does not do cross 
 module inlinig by default, and LTO only help if your 
 ldc(druntime+phobos) are built with enabled LTO[1]

 [1] 
 https://github.com/ldc-developers/ldc/issues/2182#issuecomment-343166633
Are the official LDC-releases builtin with or without LTO?
Aug 10 2020
next sibling parent Daniel Kozak <kozzi11 gmail.com> writes:
On Mon, Aug 10, 2020 at 1:15 PM Per Nordl=C3=B6w via Digitalmars-d-learn <
digitalmars-d-learn puremagic.com> wrote:

 On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote:
 I am not sure but last time I checked ldc does not do cross
 module inlinig by default, and LTO only help if your
 ldc(druntime+phobos) are built with enabled LTO[1]

 [1]
 https://github.com/ldc-developers/ldc/issues/2182#issuecomment-34316663=
3
 Are the official LDC-releases builtin with or without LTO?
AFAIK only for OSX, but Arch linux ldc package is now build with LTO enabled
Aug 10 2020
prev sibling parent kinke <kinke gmx.net> writes:
On Monday, 10 August 2020 at 11:11:57 UTC, Per Nordlöw wrote:
 Are the official LDC-releases builtin with or without LTO?
Most of them are, but not sure why that matters here (the gain is almost negligible and mainly interesting for the C++ parts - as all D files are compiled to a single object file anyway).
 On Monday, 10 August 2020 at 05:54:14 UTC, Daniel Kozak wrote:
 I am not sure but last time I checked ldc does not do cross 
 module inlinig by default,
Right, it's still experimental and has issues.
 and LTO only help if your ldc(druntime+phobos) are built with 
 enabled LTO
That's only true if (mostly non-templated) functions in druntime/Phobos are to be cross-module inlined, just like any other library. In that case, you can simply use `-flto=<thin|full> -defaultlib=phobos2-ldc-lto,druntime-ldc-lto` with LDC builds shipping with LTO druntime/Phobos and don't have to recompile druntime/Phobos manually anymore.
Aug 10 2020
prev sibling parent Daniel Kozak <kozzi11 gmail.com> writes:
On Mon, Aug 10, 2020 at 12:20 AM Per Nordl=C3=B6w via Digitalmars-d-learn <
digitalmars-d-learn puremagic.com> wrote:
 Is cross-module-inlining enabled by default in LDC when compiling
 in release mode or do I have to use explicitly flag for it? I
 can't find any such flag from the output of neither

      ldc2 -h

 nor

      ldmd2 -h

 Johan Engelen mentioned this, then experimental, flag in his
 DConf talk from 2017 [1]

 [1] https://www.youtube.com/watch?v=3DIZY67TBZ0V4
ldc2 --help-hidden | grep cross --disable-demotion - Clone multicolor basic blocks but do not demote cross scopes * --enable-cross-module-inlining=3D<value> - (*) Enable cross-module function inlining (default disabled)* --iterative-counter-promotion - Allow counter promotion across the whole loop nest. --jump-threading-across-loop-headers - Allow JumpThreading to thread across loop headers, for testing --licm-n2-threshold=3D<int> - How many instruction to cross product using AA --lsr-backedge-indexing - Enable the generation of cross iteration indexed memops =3Dcross-dso-cfi - Cross-DSO CFI =3Dcross-dso-cfi - Cross-DSO CFI --split-dwarf-cross-cu-references - Enable cross-cu references in DWO files --x86-align-branch-boundary=3D<uint
Aug 09 2020