LLVM Image Activator

David Chisnall theraven at theravensnest.org
Sat Jan 12 11:56:41 UTC 2013


Hi Nathan,

I'm very interested in making better use of LLVM in our infrastructure.  It would also be nice to be able to integrate this with rtld, so that we can load shared libraries that contain LLVM IR.

Beyond that, there are a few long-term projects that I have in mind:

- Run passes that add code for collecting profiling information before running code invoked in this way.

- Recompile on subsequent invocations based on the collected profiling information.

- Specialise installed shared libraries based on the programs that link to them, so that if foo band bar both link to libbaz, but use it in very different ways, they get different versions compiled specifically for them.

- Statically compile and cache programs invoked with the JIT, so that they are very fast on their second run.  This would probably want a periodic job to remove old caches.  

I have written code in LanguageKit for doing several of these things, but it would be nicer to have them done at the system level, rather than at the level of a front end.

I'd also like to start using the LLVM JIT for accelerating various other functions.  I have a proof-of-concept JIT for BPF that uses LLVM and I'd like to extend this to pf/ipf firewall rules.

David

On 6 Jan 2013, at 18:02, Nathan Whitehorn wrote:

> Having LLVM/clang in the base system lets us do some interesting things
> that we couldn't do with GCC. One is that LLVM ships with a JIT for LLVM
> IR as well as components of a toolchain for it (this is what Google's
> pNACL uses) and that you can end up producing binary files that are in
> IR instead of native code. The IR isn't really cross-platform, but does
> let you do CPU-specific optimizations when executed by the JIT, etc.
> 
> The attached patch causes the LLVM JIT (lli) to be built by default
> (adding ~20 seconds to buildworld on my five-year-old laptop) and adds a
> kernel image activator that invokes it when passed LLVM bitcode files.
> It's not completely finished (see the XXX comment in the middle), but it
> does work, as follows:
> 
> $ clang -emit-llvm -c -o hw.ll hw.c
> $ file hw.ll
> hw.ll: LLVM bitcode
> $ lli hw.ll
> Hello world!
> $ chmod a+x hw.ll
> $ ./hw.ll
> Hello world!
> $
> 
> Is there any interest in having features like this? It seems like this
> could provides some interesting possibilities for us and nice
> integration from having imported clang into base.
> -Nathan
> <imgact_llvm.diff>_______________________________________________
> freebsd-toolchain at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-toolchain
> To unsubscribe, send any mail to "freebsd-toolchain-unsubscribe at freebsd.org"



More information about the freebsd-arch mailing list