[LLVMdev] Strange exception in SelectionDAGBuilder

Talin viridia at gmail.com
Sat Sep 25 16:38:50 PDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100925/fba7e287/attachment.html>


More information about the llvm-dev mailing list