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.)<div>

<br></div><div>The exception I am getting occurs in this code here in SelectionDAGBuilder.cpp:</div><div><br><div><span class="Apple-style-span" style="font-family: monospace; font-size: medium; white-space: pre; ">  <b><font color="#A020F0">case</font></b> <b><font color="#5F9EA0">Intrinsic</font></b>::gcroot:</span></div>

<div><span class="Apple-style-span" style="font-family: monospace; font-size: medium; white-space: pre; "><pre>    <b><font color="#A020F0">if</font></b> (GFI) {
      <b><font color="#228B22">const</font></b> Value *Alloca = I.getArgOperand(0);
      <b><font color="#228B22">const</font></b> Constant *TypeMap = cast<Constant>(I.getArgOperand(1));

<b>      FrameIndexSDNode *FI = cast<FrameIndexSDNode>(getValue(Alloca).getNode());
</b>      GFI->addStackRoot(FI->getIndex(), TypeMap);
    }
    <b><font color="#A020F0">return</font></b> 0;</pre></span>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.)</div>

<div><br></div><div>Here's what the IR looks like:</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">  %gc_root = alloca %tart.collections.KeyError*, align 8, !dbg !55084</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">  store %tart.collections.KeyError* %7, %tart.collections.KeyError** %gc_root, align 8, !dbg !55084</font></div><div><font class="Apple-style-span" face="'courier new', monospace">  %9 = bitcast %tart.collections.KeyError** %gc_root to i8**, !dbg !55084</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">  call void @llvm.gcroot(i8** %9, i8* null), !dbg !55084</font></div></div><div><br></div><div>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.</div>

<div><br></div><div>I just sync'd to the most recent LLVM head and I still get the error.</div><div><br>-- <br>-- Talin<br>
</div></div>