pragma(inline, true) / llvmAttr("alwaysinline") cross module inlining failure

kinke noone at nowhere.com
Thu May 7 01:51:22 UTC 2020


On Wednesday, 6 May 2020 at 20:16:19 UTC, Marcel wrote:
> Hello!
> I have a simple wrapper type around LLVM's atomic intrinsics in 
> a static library, which I use in a separate, also static, 
> library. Today I noticed that even though all of the type's 
> methods are explicitly marked as forceinline, that their body 
> consists of a single instruction and that I'm using 
> "-enable-cross-module-inlining=true", all method calls are NOT 
> inlined.
> This happens regardless of whether I'm using 
> llvmAttr("alwaysinline"), pragma(inline, true) or even if I 
> remove all inlining annotations.
> Am I missing something or is this a compiler bug? Does anyone 
> know of any workaround?

This is a known bug of -enable-cross-module-inlining when 
compiling several object files in a single cmdline (the default 
when building a static library) - a function can only be emitted 
into a single object file.

The workaround is using LTO.


More information about the digitalmars-d-ldc mailing list