[LLVMdev] Accounting for code size

Sandro Magi naasking at gmail.com
Fri Sep 28 10:27:37 PDT 2007


In my quest to account for memory, I've now come to the in-memory IR,
and the generated code. I want to book the generated code memory
against the agent that is generating the code.

I see that LLVM's Function class [1] has a size function; what does
this represent and can I use it to account for the space used by the
in-memory IR?

As for generated code, the JIT [2] class simply returns a "void *"
when generating code for that function, with no size information that
I can see.

MachineCodeEmitter [3] is obtainable from the JIT class, and it
contains "BufferBegin", "BufferEnd", and "CurBufferPtr" as protected
members; if they were available, determining the generated code size
might be possible via some pointer arithmetic. Is there another way I
might be missing? Or would I have to subclass JITEmitter and add a
method to perform this calculation?

Finally, can I free the memory used by the in-memory IR after the code
is generated?

Sandro

[1] http://llvm.org/doxygen/classllvm_1_1Function.html#a27
[2] http://llvm.org/doxygen/classllvm_1_1JIT.html
[3] http://llvm.org/doxygen/classllvm_1_1MachineCodeEmitter.html



More information about the llvm-dev mailing list