[llvm-dev] ThinLTO: module-scope inline assembly blocks
Johan Engelen via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 3 06:53:52 PDT 2016
Hi all,
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).
However, I am running into trouble with module-scope inline assembly blocks.
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.
```
module asm "\09.text"
module asm "\09.globl\09foo"
module asm "\09.align\0916, 0x90"
module asm "\09.type\09foo, at function"
module asm "foo:"
module asm "\09movq %rdi, %rax"
module asm "\09rorw $8, %ax"
module asm "\09ret "
module asm "\09.size\09foo, .-foo"
module asm ""
declare zeroext i16 @foo(i16 zeroext) #0
define i32 @_simplefunction() #1 {
ret i32 1
}
```
Another module MAIN contains a function that calls ASM's `simplefunction()`.
```
define i32 @_Dmain({ i64, { i64, i8* }* } %unnamed) #0 {
%1 = call i32 @_simplefunction() #1
ret i32 %1
}
declare i32 @_simplefunction() #1
```
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.
(note that `foo` is not called anywhere)
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.
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?
(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)
Thanks!
Cheers,
Johan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/46e3ad4e/attachment.html>
More information about the llvm-dev
mailing list