[LLVMdev] Proposal: support object file-based on-disk module format

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Aug 25 15:19:22 PDT 2014


Sorry for the delay in replying.

I agree that this looks like an interesting feature to have. Having
worked with gcc's lto in the past, the one thing I would like to avoid
is having a failure mode where a non-LTO build is done, which is the
case with a complete fat native object. I understand that is not the
case in your current proposal since the object files only have
auxiliary metadata, not text sections. This is just something to keep
in mind as things evolve.

If I remember correctly one of the issues with the original patches
was the handling of MemoryBuffer ownership. Trunk has switched to
object::Binary holding just a reference to the memory, so this should
be easier to implement now.

So, it looks like everyone is OK at least with the idea of supporting
IR-in-Object, so would you mind rebasing your patches on top of
current trunk?

Thanks,
Rafael



On 6 July 2014 21:57, Peter Collingbourne <peter at pcc.me.uk> wrote:
> Hi,
>
> Over in [1] we've been discussing adding support in LTO for an object
> file-based on-disk module format. Rafael suggested that I send a proposal
> to this list; this is that proposal.
>
> As motivation, consider a compiler that needs to store metadata in the
> LTO object file that may need to be read by future compilation steps,
> such as the "export data" used by some Go compilers [2]. Such metadata
> might also need to be read by external tools which do not know about LLVM,
> so a good choice of file format would be something relatively stable and
> well understood, readable without depending on LLVM and compatible with the
> non-LTO scenario. This lends itself to the platform's native object file
> format being a good candidate for the outermost file format, such that the
> metadata and IR are stored in separate sections.
>
> The basic proposal is that as an alternative on-disk representation for IR, we
> also support native object files (i.e. ELF/COFF/Mach-O) with a section named
> '.llvmbc' containing the bitcode in the same format that we are using now,
> and no other (allocatable) sections. The actual support needed in LLVM would
> be limited to consumers, i.e. LTO infrastructure: linker plugins, llvm-ar,
> llvm-nm etc. We would not necessarily need to teach other bitcode consumers
> (e.g. llvm-dis) about this format or add any producers to the tree, but
> it may be useful as a matter of convenience to do so.
>
> We can also consider extending this format by generating code into the
> object file, such as for functions which we believe at compile time to
> be cold, or for all functions if we want the decisions to be made at link
> time. This may be beneficial for C/C++ compilation as it may allow us to
> parallelize/deduplicate the code generation work for at least some functions.
>
> Thanks,
> --
> Peter
>
> [1] http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140630/224359.html
> [2] http://golang.org/doc/install/gccgo#Imports
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list