Thanks for the review Gordon.<br><br><div class="gmail_quote">On Tue, Nov 1, 2011 at 2:21 AM, Gordon Henriksen <span dir="ltr"><<a href="mailto:gordonhenriksen@mac.com">gordonhenriksen@mac.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On <a href="tel:2011-10-31" value="+4520111031">2011-10-31</a>, at 17:21, Nicolas Geoffray wrote:<br>
<br>
> Here's a patch to allow a GCStrategy to customize the places where it wants to insert safe points. I'm not sure who maintains the GC code today in LLVM (I'd be happy to take ownership, if needed).<br>
><br>
> The patch just adds up a custom safepoints flag, similar to the way the GCStrategy can customize intrinsics lowering, or roots initialization. It works pretty well, as I've tested it on VMKit. So the patch in itself should not be controversial.<br>

<br>
</div>Seems a perfectly reasonable patch on its own merits.<br>
<br>
I would be curious what your findCustomSafePoints implementation looks like. Perhaps it's possible to extract some of it into the framework.<br></blockquote><div><br></div><div>The code for my findCustomSafePoints is like this:</div>
<div><br></div><div><div>void MyGC::findCustomSafePoints(GCFunctionInfo& FI, MachineFunction &MF) {</div><div>  for (MachineFunction::iterator BBI = MF.begin(),</div><div>                                 BBE = MF.end(); BBI != BBE; ++BBI) {</div>
<div>    for (MachineBasicBlock::iterator MI = BBI->begin(),</div><div>                                     ME = BBI->end(); MI != ME; ++MI) {</div><div>      if (MI->getDesc().isCall()) {</div><div>               /// Standard code need for adding a post call safe point;</div>
<div>      } else if (MI->getDebucLoc().getCol() == 1) {</div><div>              /// Standard code need for adding a post call safe point;</div><div>      }</div><div>  }</div><div>}</div></div><div><br></div><div>So it really looks like what we already have, except this special trick about checking the debug location. Piggy backing on the debug location is easy and works for me because:</div>
<div>1) Debug locations are passed from LLVM Instructions to MachineInstruction</div><div>2) I don't have column numbers in my front-end.</div><div><br></div><div>The instructions that get this special marker on the debug location are instructions that may trigger a segmentation fault. Because I enter a signal handler, that may invoke a collection, I need to know the roots at the faulting instruction's address.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
> Chris, I'd like to discuss with you on how we can improve the current GC framework to take advantage of metadata. The reason I add this custom safe point creation method is because it's difficult for a front-end to pass custom information to the GC framework. And I think metadata could help us in this situation. Ideally, I'd like to get to a point where we can write:<br>

><br>
> 15 = load %MyPointer* %2 !safepoint<br>
><br>
> And the GCStrategy would find this metadata information in the MachineInstruction (because the safe points are created based on MachineInstruction). This solution looks very much like the !nontemporal metadata.<br>
><br>
> Unfortunately, it looks like metadata are not passed down to MachineInstruction. How could we achieve that? Should we write custom code in the Instruction -> MachineInstruction transformation to pass down that !safepoint metadata?<br>

<br>
</div>Could such a program survive IR optimizations intact?<br></blockquote><div><br></div><div>Well, we must be sure that any instruction that is a safepoint does get some metadata associated with it. If such instruction does not get this metadata, then then program would not survive. So the 'safepoint' metadata *must* be preserved across optimizations if the instruction gets emitted.</div>
<div> </div><div>Nicolas</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888"><br>
— Gordon</font></blockquote></div><br>