Johan Engelen via llvm-dev
2016-Oct-03 15:07 UTC
[llvm-dev] ThinLTO: module-scope inline assembly blocks
With `save-temps` as plugin option, I get extra files for the MAIN module (called `a.o`): `a.o.opt.bc` and `a.thinlto.bc`. The `a.thinlto.bc` file contains nothing, only `source_filename = ...` . The `a.o.opt.bc` (this looks like the result after ThinLTO importing and optimization) contains the assembly block that it should not have: ``` 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 "" ``` The asm is the same as in the other module (where it _should_ be defined), and the linkage has not been changed. Thanks for the help, Johan On Mon, Oct 3, 2016 at 4:45 PM, Teresa Johnson <tejohnson at google.com> wrote:> Oh sorry, misunderstood and thought you were implementing in a new linker. > For gold you can pass -Wl,-plugin-opt,save-temps and look at the bitcode > after each phase of ThinLTO, e.g. I think the files will have .3.import.bc > extensions. > > Teresa > > On Mon, Oct 3, 2016 at 7:42 AM, Johan Engelen <jbc.engelen at gmail.com> > wrote: > >> On Mon, Oct 3, 2016 at 4:27 PM, Teresa Johnson <tejohnson at google.com> >> wrote: >> >>> >>> >>> On Mon, Oct 3, 2016 at 6:53 AM, Johan Engelen via llvm-dev < >>> llvm-dev at lists.llvm.org> wrote: >>> >>>> 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. >>>> >>> >>> Are you adding the support using the new LTO API or using the libLTO C >>> interfaces? >>> >> >> Perhaps I don't fully understand, but I think the answer is: neither :) >> What I do is output the module as bitcode with the module summary index >> added (`llvm::WriteBitcodeToFile`, summary index created with >> `llvm::ModuleSummaryIndexBuilder`). This is then passed to the system >> linker. The problems arise with ld.gold + LLVMgold plugin. I am using LLVM >> 3.9.0. >> >> > > > -- > Teresa Johnson | Software Engineer | tejohnson at google.com | > 408-460-2413 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/8522be0c/attachment.html>
Teresa Johnson via llvm-dev
2016-Oct-03 15:24 UTC
[llvm-dev] ThinLTO: module-scope inline assembly blocks
On Mon, Oct 3, 2016, 8:08 AM Johan Engelen <jbc.engelen at gmail.com> wrote:> With `save-temps` as plugin option, I get extra files for the MAIN module > (called `a.o`): `a.o.opt.bc` and `a.thinlto.bc`. >What revision is your gold plugin built from? I would expect more temp files.> The `a.thinlto.bc` file contains nothing, only `source_filename = ...` . >This is a dump of the combined index. llvm-dis won't show that, so that's not unexpected. The `a.o.opt.bc` (this looks like the result after ThinLTO importing and> optimization) contains the assembly block that it should not have: > ``` > 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 "" > ``` > The asm is the same as in the other module (where it _should_ be defined), > and the linkage has not been changed. >Will try to reproduce later this morning when I'm back in front of my computer. Teresa> Thanks for the help, > Johan > > > On Mon, Oct 3, 2016 at 4:45 PM, Teresa Johnson <tejohnson at google.com> > wrote: > > Oh sorry, misunderstood and thought you were implementing in a new linker. > For gold you can pass -Wl,-plugin-opt,save-temps and look at the bitcode > after each phase of ThinLTO, e.g. I think the files will have .3.import.bc > extensions. > > Teresa > > On Mon, Oct 3, 2016 at 7:42 AM, Johan Engelen <jbc.engelen at gmail.com> > wrote: > > On Mon, Oct 3, 2016 at 4:27 PM, Teresa Johnson <tejohnson at google.com> > wrote: > > > > On Mon, Oct 3, 2016 at 6:53 AM, Johan Engelen via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > 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. > > > Are you adding the support using the new LTO API or using the libLTO C > interfaces? > > > Perhaps I don't fully understand, but I think the answer is: neither :) > What I do is output the module as bitcode with the module summary index > added (`llvm::WriteBitcodeToFile`, summary index created with > `llvm::ModuleSummaryIndexBuilder`). This is then passed to the system > linker. The problems arise with ld.gold + LLVMgold plugin. I am using LLVM > 3.9.0. > > > > > -- > Teresa Johnson | Software Engineer | tejohnson at google.com | > 408-460-2413 > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/8359d2db/attachment.html>
Mehdi Amini via llvm-dev
2016-Oct-03 16:17 UTC
[llvm-dev] ThinLTO: module-scope inline assembly blocks
> On Oct 3, 2016, at 8:07 AM, Johan Engelen via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > With `save-temps` as plugin option, I get extra files for the MAIN module (called `a.o`): `a.o.opt.bc` and `a.thinlto.bc`.I’d expect as temps `a.thinlto.bc` for the index + one file per input. Also there should be a number like: `a.o.4.opt.bc` Can you attach the generated temp files? Thanks, — Mehdi> The `a.thinlto.bc` file contains nothing, only `source_filename = ...` . > The `a.o.opt.bc` (this looks like the result after ThinLTO importing and optimization) contains the assembly block that it should not have: > ``` > 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 "" > ``` > The asm is the same as in the other module (where it _should_ be defined), and the linkage has not been changed. > > Thanks for the help, > Johan > > > On Mon, Oct 3, 2016 at 4:45 PM, Teresa Johnson <tejohnson at google.com <mailto:tejohnson at google.com>> wrote: > Oh sorry, misunderstood and thought you were implementing in a new linker. For gold you can pass -Wl,-plugin-opt,save-temps and look at the bitcode after each phase of ThinLTO, e.g. I think the files will have .3.import.bc extensions. > > Teresa > > On Mon, Oct 3, 2016 at 7:42 AM, Johan Engelen <jbc.engelen at gmail.com <mailto:jbc.engelen at gmail.com>> wrote: > On Mon, Oct 3, 2016 at 4:27 PM, Teresa Johnson <tejohnson at google.com <mailto:tejohnson at google.com>> wrote: > > > On Mon, Oct 3, 2016 at 6:53 AM, Johan Engelen via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > 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. > > Are you adding the support using the new LTO API or using the libLTO C interfaces? > > Perhaps I don't fully understand, but I think the answer is: neither :) > What I do is output the module as bitcode with the module summary index added (`llvm::WriteBitcodeToFile`, summary index created with `llvm::ModuleSummaryIndexBuilder`). This is then passed to the system linker. The problems arise with ld.gold + LLVMgold plugin. I am using LLVM 3.9.0. > > > > > -- > Teresa Johnson | Software Engineer | tejohnson at google.com <mailto:tejohnson at google.com> | 408-460-2413 <tel:408-460-2413> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/79b432fa/attachment.html>
Johan Engelen via llvm-dev
2016-Oct-03 16:40 UTC
[llvm-dev] ThinLTO: module-scope inline assembly blocks
The plugin version (and LLVM) are LLVM 3.9.0 (the release source tarball). I've attached the source files and the temporary files generated. `a.o` is the "MAIN" module. `b.o` is the "ASM" module. The error I get is: /usr/bin/ld: error: a.o.thinlto.o: multiple definition of 'foo' /usr/bin/ld: b.o.thinlto.o: previous definition here (the files depend on D runtime lib, so upon succes you should see missing symbol errors :-) Thanks, Johan On Mon, Oct 3, 2016 at 6:17 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:> > On Oct 3, 2016, at 8:07 AM, Johan Engelen via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > With `save-temps` as plugin option, I get extra files for the MAIN module > (called `a.o`): `a.o.opt.bc` and `a.thinlto.bc`. > > > I’d expect as temps `a.thinlto.bc` for the index + one file per input. > Also there should be a number like: `a.o.4.opt.bc` > > Can you attach the generated temp files? > > Thanks, > > — > Mehdi > > > > The `a.thinlto.bc` file contains nothing, only `source_filename = ...` . > The `a.o.opt.bc` (this looks like the result after ThinLTO importing and > optimization) contains the assembly block that it should not have: > ``` > 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 "" > ``` > The asm is the same as in the other module (where it _should_ be defined), > and the linkage has not been changed. > > Thanks for the help, > Johan > > > On Mon, Oct 3, 2016 at 4:45 PM, Teresa Johnson <tejohnson at google.com> > wrote: > >> Oh sorry, misunderstood and thought you were implementing in a new >> linker. For gold you can pass -Wl,-plugin-opt,save-temps and look at the >> bitcode after each phase of ThinLTO, e.g. I think the files will have >> .3.import.bc extensions. >> >> Teresa >> >> On Mon, Oct 3, 2016 at 7:42 AM, Johan Engelen <jbc.engelen at gmail.com> >> wrote: >> >>> On Mon, Oct 3, 2016 at 4:27 PM, Teresa Johnson <tejohnson at google.com> >>> wrote: >>> >>>> >>>> >>>> On Mon, Oct 3, 2016 at 6:53 AM, Johan Engelen via llvm-dev < >>>> llvm-dev at lists.llvm.org> wrote: >>>> >>>>> 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. >>>>> >>>> >>>> Are you adding the support using the new LTO API or using the libLTO C >>>> interfaces? >>>> >>> >>> Perhaps I don't fully understand, but I think the answer is: neither :) >>> What I do is output the module as bitcode with the module summary index >>> added (`llvm::WriteBitcodeToFile`, summary index created with >>> `llvm::ModuleSummaryIndexBuilder`). This is then passed to the system >>> linker. The problems arise with ld.gold + LLVMgold plugin. I am using LLVM >>> 3.9.0. >>> >>> >> >> >> -- >> Teresa Johnson | Software Engineer | tejohnson at google.com | >> 408-460-2413 >> > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/a3bdbf2a/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: Archive.zip Type: application/zip Size: 10920 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161003/a3bdbf2a/attachment.zip>