[llvm-commits] [PATCH] New external2availableexternally pass (issue166075)

Jeffrey Yasskin jyasskin at google.com
Mon Dec 7 16:14:27 PST 2009


On Mon, Dec 7, 2009 at 1:06 PM, Jeffrey Yasskin <jyasskin at google.com> wrote:
> On Mon, Dec 7, 2009 at 12:59 PM, Chris Lattner <clattner at apple.com> wrote:
>>
>> On Dec 7, 2009, at 11:52 AM, Jeffrey Yasskin wrote:
>>
>>> Anyone have comments?
>>
>> Who are the expected clients of this?  It seems pretty special purpose to go into mainline.
>
> People writing JITs are likely to use it to provide definitions of
> their runtime library functions. Static compilers could use it too if
> they ship with a compiled runtime but also want to be able to inline
> bits of the runtime into their output, without making those bits
> builtins.

That is, take the author of a new language.
1. They write a compiler, taking their language to IR.
2. They write a standard library, which they'll ship with their
compiler. To make compilation fast, they generate native code from the
library and install it with their compiler.
3. They notice that calls into their standard library could benefit
from inlining. There are two things they could do here:
  a. Don't install native code; instead install .bc files. Load those
into the module of each translation unit. This means that for stdlib
calls that aren't inlined, every compilation needs to generate code.
That's especially problematic for a JIT, but also wastes time for a
static compiler.
  b. Generate a .bc file with the library functions defined, but
marked available_externally. This lets the optimizers inline the
definitions, but non-inlined definitions just call out to the
pre-compiled native code.

3b is the tactic this pass is designed for. The language author uses it like:
1. Write the compiler.
2. Write the standard library.
3. Compile it to bitcode.
4. Generate a .o or .so from the bitcode, and install that with the
compiler. This gets linked with every output binary.
5. Run external2availableexternally over the bitcode file, to produce
a stdlib.bc. This gets loaded into the Module of every translation
unit to facilitate inlining.

Jeffrey




More information about the llvm-commits mailing list