[LLVMdev] [cfe-dev] Reducing the size of LLVM and clang

Mark Lacey 641 at rudkx.com
Mon Jun 14 21:22:49 PDT 2010


Is that really going to make a significant difference?

I've been looking at the same issue, in my case trying to make a
simple JIT (using only LLVM at the time, not trying to use clang to
parse and then JIT, but rather deserializing bytecode and JIT it).

I made the simplest example I could based on my limited knowledge of
the interfaces, and even linking with -dead_strip and optimizing for
size it's still 1.25MB+. If I add any optimization passes (InstCombine
in particular seems to pull in a lot of code), the static code size
(in the text section) balloons up past 4MB. (This is all on Mac OS
using g++ to compile; on Windows using VC, compiling for size and
using /OPT:REF,ICF, the result is around 30% smaller).

Two things I noticed:
- Though I've configured for only x86_64, I get both 32-bit and 64-bit
code generation support according to llc --version; I don't know how
much overhead having 32-bit support is, but I really want to make the
smallest JIT possible, so excluding that would be nice.
- Although I only care about JITting, the execution engine interface
seems to pull in code for interpreting as well; I haven't verified
that this is the absolutely the case, but it seems to make a dynamic
choice and looking at the code I would assume the interpreter is
getting pulled in.

I've watched Nate Begeman's excellent talk from 2008 on making a fast
JIT (as well as the talk on implementing OpenCL, which goes over the
same points). I'm wondering if anyone has advice on making a fast
*small* JIT as well.

Thanks,

Mark

On Mon, Jun 14, 2010 at 7:08 AM, Nicolas Capens
<nicolas.capens at gmail.com> wrote:
> Hi Robert,
>
> Try removing intrinsics you don't need. In particular in Intrinsics.td you
> can comment out some of the includes at the bottom of the file.
>
> Cheers,
>
> Nicolas
>
>
> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On
> Behalf Of Robert Quill
> Sent: Thursday, June 10, 2010 15:06
> To: cfe-dev at cs.uiuc.edu; llvmdev at cs.uiuc.edu
> Subject: [LLVMdev] Reducing the size of LLVM and clang
>
> Hi all,
>
> We are looking to try and reduce the size of the clang and LLVM
> libraries and were wondering if anyone had any advice on how to do this.
> All we want is to be able to compile from a single language to a single
> back-end and for that back-end to emit instructions; we don't care about
> anything else. Currently we are building LLVM to use only our target, so
> that is OK. Is it possible to build clang with support for only one
> language? Or does anyone else have any tips about how to reduce the size
> of the libraries?
>
> Thanks for your help,
> Rob



More information about the llvm-dev mailing list