[LLVMdev] non-pointer gcroot

Scott Graham sgraham at gmail.com
Sun Nov 9 11:37:26 PST 2008


On Fri, Nov 7, 2008 at 6:40 PM, Gordon Henriksen <gordonhenriksen at me.com> wrote:

> Using the new support for first-class aggregate values, you should be
> able to rewrite the above code to use Constant::getNullValue
> regardless of the type of the alloca. There needn't be a special-case
> for !isa<PointerType>((*I)->getType()->getElementType()).
>
> However, I hesitate to recommend this route; I think it boxes in from
> supporting escape analysis (where pointer fields within a stack-
> allocated struct would need to be initialized). I'd suggest you gcroot
> pointers to your fat pointers instead. This needn't imply any changes
> to your fat pointers in the heap, and constitutes a trivial change to
> a stalk walker.


Hi Gordon

Thanks, I'll look forward to getting up to 2.4/head for the new and
improved getNullValue.

I'm not sure I understand your suggestion. The concern is that a
future optimization pass may be hampered by having structs rooted? In
my front end, the fat pointers will only ever be stack allocated
(never in the heap), so it seems strange to add the extra indirection.
I suppose the loads through the fat-pointer-pointer should be
optimized away anyway?

> P.S. — Avoid using Type::getTypeID; it's an implementation detail for
> the templates in llvm/support/Casing.h: isa<>, cast<>, dyn_cast<>, etc.

Noted, thank you.

scott




More information about the llvm-dev mailing list