[LLVMdev] Running Pool Allocated programs

Ricardo rmivs-lists at yahoo.com
Sat Apr 2 16:33:23 PST 2005


Thanks for the answer

I am trying to test the PA with a program very similar to the one used as an example in the paper
located here:

http://llvm.cs.uiuc.edu/pubs/2003-04-29-DataStructureAnalysisTR.html

The program is as follows:

==========================
struct list { struct list  *Next; }; 

struct list *makeList (int Num) {
	struct list  *New = malloc ( sizeof ( struct list ) );
	New->Next = Num ? makeList (Num-1) : 0;
	return New;
}
int main() {
	struct list  *X = makeList(10); 
}
==========================

After applying the PA to it, the output is something like this:

==========================
int main(void) {
  signed char *ltmp_2_5;
  struct l_struct_2E_list *l6_tmp_2E_7_2E_i2;

#if defined(__GNUC__) && !defined(__llvm__)
#if defined(i386) || defined(__i386__) || defined(__i386)
{short FPCW;__asm__ ("fnstcw %0" : "=m" (*&FPCW));
FPCW=(FPCW&~0x300)|0x200;__asm__("fldcw %0" :: "m" (*&FPCW));}
#endif
#endif
  poolinit((&l2_GlobalPool), 4u, 4u);
  ltmp_2_5 = malloc(4u);
  l6_tmp_2E_7_2E_i2 = l1_makeList((&l2_GlobalPool), 8);
  *(&((struct l_struct_2E_list *)ltmp_2_5)->field0) = l6_tmp_2E_7_2E_i2;
  return ((int )/*UNDEF*/0);
}
==========================

My question is: why is this malloc necessary?

ltmp_2_5 = malloc(4u);

Shouldn't be the result a program with this malloc replaced by poolalloc?
Should I include a special flag to achieve this?

I am using this line:

opt -load ~/llvm/install/lib/libpoolalloc.so -poolalloc 

and also with -pooloptimize

Thanks in advance




--- Chris Lattner <sabre at nondot.org> wrote:

> On Sat, 2 Apr 2005, Ricardo wrote:
> > Hello,
> > I am trying to run a program optimized with the Pool Allocation, but I am receiving this
> error:
> >
> > ====================
> >
> > *** 4 DYNAMIC POOLS INITIALIZED ***
> >
> > *** 4 DYNAMIC POOLS ALLOCATED FROM ***
> >
> > MaxHeapSize = 0.062500KB  HeapSizeAtExit = 0.062500KB   NOTE: only valid if using
> > Heuristic=AllPools and no bumpptr/realloc!
> > ====================
> 
> This output is what happens when you link with the debug version of the 
> runtime library.  If you rebuild the FL2Allocator with 'make 
> ENABLE_OPTIMIZED=1' and link with the result, you shouldn't get this.
> 
> > I have tried to link the program with the Analysis and with Datastructure libs:
> > llvm-gcc -o test test.opt.bc -lpoolalloc -lpoolalloc_rt -lLLVMDataStructure -lLLVMAnalysis
> > But I am still receiving the error.
> 
> You should only need -lpoolalloc_rt.
> 
> For the record, I usually do (effectively) this to test the pool 
> allocator:
> 
> llvm-gcc *.c -o program         # compile&link whole prog with LLVM
> opt -load ... -poolalloc program.bc ... -o program.pa.bc
> llc program.pa.bc -march=c -o program.pa.cbe.c
> gcc -fno-strict-aliasing -O2 program.pa.cbe.c -o program.pa
> -L~/llvm/projects/llvm-poolalloc/Release/lib/ -lpoolalloc_rt
> 
> Alternatively, if you want a quick test, you can do the first two steps, 
> then:
> 
>    lli -load ~/llvm/projects/llvm-poolalloc/Release/lib/libpoolalloc_rt.so program.pa.bc
> 
> If you're on a target that supports the JIT.
> 
> > Another question, I do not want to use the bump ptr optimization, and I suppose that the right
> > heuristic for that is AllNodes? But if I want to use it, what is the right heuristic?
> 
> The AllNodes heuristic is the only one that is substantially tested.  I 
> would recommend it, none of the others have any significant performance 
> benefit anyway.
> 
> The bump pointer and other opts are a seperate option -pooloptimize, which 
> can be run after -poolalloc.  It does not work with -pointercompress 
> though.
> 
> > Also, if I want to use the Pointer Compression, I suppose that I have to 
> > use the -pointercompress switch with opt or what?
> 
> Yes, if you use it, don't specify -poolalloc manually.
> 
> -Chris
> 
> -- 
> http://nondot.org/sabre/
> http://llvm.cs.uiuc.edu/
> 




More information about the llvm-dev mailing list