<div dir="ltr">Hi all,<div>  I am trying to add ThinLTO to the LDC compiler. It seems to work well on Mac (XCode 8) and Ubuntu (ld.gold + LLVMgold plugin).</div><div>However, I am running into trouble with module-scope inline assembly blocks.</div><div><br></div><div>I have a module ASM with a function `foo` defined in an inline assembly block (and an LLVM IR `declare @foo()` for it). There is also a "normal" function `void simplefunction()` defined in the module.</div><div>```</div><div>module asm "\09.text"</div><div>module asm "\09.globl\09foo"</div><div>module asm "\09.align\0916, 0x90"</div><div>module asm "\09.type\09foo,@function"</div><div>module asm "foo:"</div><div>module asm "\09movq %rdi, %rax"</div><div>module asm "\09rorw $8, %ax"</div><div>module asm "\09ret "</div><div>module asm "\09.size\09foo, .-foo"</div><div>module asm ""</div><div><br></div><div>declare zeroext i16 @foo(i16 zeroext) #0</div><div><br></div><div>define i32 @_simplefunction() #1 {</div><div>  ret i32 1</div><div>}</div><div>```</div><div><br></div><div>Another module MAIN contains a function that calls ASM's `simplefunction()`.</div><div>```</div><div>define i32 @_Dmain({ i64, { i64, i8* }* } %unnamed) #0 {</div><div>  %1 = call i32 @_simplefunction() #1</div><div>  ret i32 %1</div><div>}</div><div>declare i32 @_simplefunction() #1</div><div>```</div><div><br></div><div>Then these two modules are passed to the linker, using ThinLTO, thus bitcode files with .o extension and module summaries added. The linker reports a multiple definition error for the inline assembly function.</div><div>(note that `foo` is not called anywhere)</div><div><br></div><div>I suspect that when ThinLTO decides to import a function from another module for inlining, the other module's module-scope assembly blocks are also imported, which later result in the multiple definition problems.</div><div><br></div><div>My question: is this known, intended, or otherwise broken on _my_ end? Or perhaps is it a bug and importing from modules with module-scope assembly should be disabled / should not import the module-scope asm?</div><div><br></div><div>(I can "fix" things on my end by disabling ThinLTO when there is a module-scope asm block, but perhaps there should be a proper fix in LLVM)</div><div><br></div><div>Thanks!</div><div><br></div><div>Cheers,</div><div>  Johan</div><div><br></div></div>