[LLVMdev] Including / Linking with Pool Allocation

John Criswell criswell at cs.uiuc.edu
Tue Jun 2 15:35:20 PDT 2009

Patrick Alexander Simmons wrote:
> Hi,
> I'm starting to code a pass which uses the analysis results of pool 
> allocation, and I've run into a bit of a snag.  Following the advice at 
> [http://llvm.org/docs/WritingAnLLVMPass.html], I've put my new pass in 
> the lib/Transforms subdirectory of the llvm checkout.  I have the pool 
> allocation transformation checked out in projects/llvm-poolalloc.
First, while I am a firm believer in the Writing an LLVM Pass document,
it is giving you bad advice (IMHO).  What you want to do is to create an
LLVM Project; that way, your code is outside of the LLVM source tree and
can be more easily maintained in a revision control system of your
choice.  Information on LLVM projects is here:

> My problem is that the pool allocation header files are not in my pass's 
> include path.  I assume I need to modify the Makefile somehow to correct 
> this and that I should perhaps also add a line to make it link with the 
> pool allocation .so files, but I don't know the proper way to do this.  
> Could someone help?
To add extra flags to the gcc command line during compilation, use the
following in the Makefile:

CFLAGS += -I<directory of include files>
CXXFLAGS += -I<directory of include files>
CPPFLAGS += -I<directory of include files>

This will tell make to use the -I flag to find the header files you need.

You shouldn't need to link in poolalloc.so; you will either use the
-load option to load poolalloc.so and your pass into the opt program, or
you will need to write your own program (akin to the pa program in
poolalloc/tools/pa) that links in your pass and poolalloc.so and
schedules the pool allocation pass and your pass to be run by the

-- John T.

P.S. Note that I've used poolalloc.so as the name of the dynamically
loadable object that contains the pool allocation pass.  I'm not sure if
I've got the name correct, and the name will vary depending on OS (e.g.,
poolalloc.dylib on Mac OS X).

> Thanks,
> --Patrick
> _______________________________________________
> 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