[LLVMdev] Secure Virtual Machine

Sandro Magi naasking at gmail.com
Fri Jun 15 14:02:35 PDT 2007


On 6/15/07, John Criswell <criswell at cs.uiuc.edu> wrote:
> If you just need to partition the heap into multiple heaps, then the
> easiest thing to do would be to replace the use of malloc/free
> instructions with calls to library functions that implement your
> segmented heap allocation/free functions.
>
> For example, in the Automatic Pool Allocation work
> (http://llvm.org/pubs/2005-05-21-PLDI-PoolAlloc.html), we have an LLVM
> pass that changes malloc instructions:
>
> %tmp = malloc struct {i8}
>
> ... into calls to an allocation function that takes a pool identifier
> and an allocation size as arguments (in this work, we segregated the
> heap based upon pointer analysis results):
>
> %tmp = call %poolalloc (sbyte * PoolID, uint 8)
>
> The poolalloc function is then implemented as a run-time library
> (written in C) that is compiled and linked into the program (either as a
> native code library or an LLVM bytecode library).
>
> You could do something similar to implement multiple heaps.

Ah, I didn't realize passes could do such transformations. I'll read
up on them further then, thanks. :-)

> Doing GC may require using the LLVM GC intrinsics as described in this
> document (http://llvm.org/docs/GarbageCollection.html), but just
> segmenting the heap into multiple heaps should not require any new
> instructions or intrinsics to be added.

Hmm, I don't see how the current GC intrinsics could be used with two
different heaps, particularly if each heap is GC'd with its own
algorithm. It seems like you would need a pass like the one you
describe above to specify a heap each time you mark a root, or
allocate, which would require your own augmented intrinsics, or
equivalent calls inserted via a pass.

Sandro



More information about the llvm-dev mailing list