[LLVMdev] Strange exception in SelectionDAGBuilder

nicolas geoffray nicolas.geoffray at gmail.com
Sat Sep 25 23:56:26 PDT 2010


Hi Talin,

I think that the framework for GC assumes llvm.gcroot to be in the first
block. If it is not the case in your example, it will break these
assumptions.

Nicolas

On Sun, Sep 26, 2010 at 1:38 AM, Talin <viridia at gmail.com> wrote:

> I'm working on the code to handle GC tracing of "intermediate values" (as
> described in the GC doc), and I've run into a weird problem. (Note, this has
> nothing to do with the patch I have proposed, this error occurs with regular
> old pointer-allocas.)
>
> The exception I am getting occurs in this code here in
> SelectionDAGBuilder.cpp:
>
> *case* *Intrinsic*::gcroot:
>
>     *if* (GFI) {
>       *const* Value *Alloca = I.getArgOperand(0);
>       *const* Constant *TypeMap = cast<Constant>(I.getArgOperand(1));
> *      FrameIndexSDNode *FI = cast<FrameIndexSDNode>(getValue(Alloca).getNode());*      GFI->addStackRoot(FI->getIndex(), TypeMap);
>     }
>     *return* 0;
>
> Specifically, the cast from SDNode to FrameIndexSDNode fails because the
> node type is DYNAMIC_STACKALLOC, while this code is expecting the node type
> to be "FrameIndex" or "TargetFrameIndex". (I don't know what either of these
> mean, I'm just telling you what the debugger is telling me.)
>
> Here's what the IR looks like:
>
>   %gc_root = alloca %tart.collections.KeyError*, align 8, !dbg !55084
>   store %tart.collections.KeyError* %7, %tart.collections.KeyError**
> %gc_root, align 8, !dbg !55084
>   %9 = bitcast %tart.collections.KeyError** %gc_root to i8**, !dbg !55084
>   call void @llvm.gcroot(i8** %9, i8* null), !dbg !55084
>
> As you can see, it's just creating an alloca of a pointer, bitcasting it to
> i8**, and passing it to llvm.gcroot, just like it does in a hundred other
> places. But in this place, for some reason, the SelectionDAGBuilder isn't
> working.
>
> I just sync'd to the most recent LLVM head and I still get the error.
>
> --
> -- Talin
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100926/1b7516b6/attachment.html>


More information about the llvm-dev mailing list