[LLVMdev] Proposal for improving llvm.gcroot (summarized)

Jay Foad jay.foad at gmail.com
Fri Apr 1 01:58:51 PDT 2011


On 30 March 2011 19:08, Talin <viridia at gmail.com> wrote:
> llvm.gc.declare(alloca, meta). This intrinsic marks an alloca as a garbage
> collection root. It can occur anywhere within a function, and lasts either
> until the end of the function, or a until matching call to
> llvm.gc.undeclare().
> llvm.gc.undeclare(alloca). This intrinsic unmarks and alloca, so that it is
> no longer considered a root from that point onward.

Hi Talin,

What changes to code generation would be necessary to support this?

Is there any intention of supporting a collector that has static stack
maps for each function, i.e. a table telling you, for each point in
the code, where all the roots are on the stack (similar to unwind info
for exception handling)? If so, I think it's a bit dodgy to use
intrinsic function calls to mark the start/end of the lifetime of a GC
root, because function calls are inherently dynamic. For example, you
can't represent this code with a static stack map:

if (cond) {
  llvm.gc.declare(foo, bar);
}
...
// foo may or may not be a root here
...
if (cond) { // same condition as above
  llvm.gc.undeclare(foo);
}

Even if you're careful not to generate code like this in your front
end, how can you guarantee that LLVM optimisation passes won't
introduce it?

The old llvm.dbg.region.start and llvm.dbg.region.end had the same
kind of problem.

Thanks,
Jay.



More information about the llvm-dev mailing list