<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div>On Apr 28, 2008, at 10:50, Jonathan S. Shapiro wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Sun, 2008-04-27 at 22:34 -0400, Gordon Henriksen wrote:<br><blockquote type="cite">On 2008-04-27, at 21:29, Lane Schwartz wrote:<br></blockquote><blockquote type="cite"><blockquote type="cite">Since this is a simple copying collector, the functions llvm_gc_read <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">and llvm_gc_write won't really do much:</span></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { return <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">*FieldPtr; }</span></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr) <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">{ *FieldPtr = V; }</span></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">You can just emit loads and stores directly if your read/write <span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">barriers do nothing. Also, there's nothing special about the llvm_gc_read or llvm_gc_write functions any more; they will not be called unless you call them yourself.</span></blockquote></blockquote><div><br></div><div>Here, I was making two points. First and foremost, the user symbols llvm_gc_read and llvm_gc_write are not special any more, so Lane shouldn't bother with them. :)</div><div><br></div><div>Secondly, it's not strictly necessary to use the barrier intrinsics, which is the point you're addressing.</div><br><blockquote type="cite">Gordon:<br><br>Since GC strategies change as implementations mature, is there a way to go ahead and emit these calls, but then in a simple implementation indicate somewhere that they should be trivially inlined? This would allow us to debug things without imposing performance penalties on the simple implementation.<br><br>Actually, I can see wanting to inline these even in barrier-oriented GC implementations...<br></blockquote></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><br class="khtml-block-placeholder"></div><div>Indeed so! If you do use the @llvm.gcread and @llvm.gcwrite intrinsics (not to be confused with the above functions), they will be transparently converted to simple loads and stores, so there's “no cost” to using them. As the implementation matures, an llc plugin can trivially substitute a write barrier using the performCustomLowering hook:</div><div><div><br><div></div></div></div></span></span></span></span></span></div></span></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><a href="http://llvm.org/docs/GarbageCollection.html#custom">http://llvm.org/docs/GarbageCollection.html#custom</a></blockquote><div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Trebuchet MS; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><div><br></div><div>This gives quite detailed control. The plugin could inline just a "hot" codepath on a barrier and keep a cold one out of line, for instance. (Note: Near-future plan is to use IR-to-selection-DAG lowering rather than IR-to-IR for this hook, if you're working in this area.)</div><div><br></div><div>However, GC lowering happens just before code generation, after any IR optimizations; thus, the use of the intrinsics can inhibit IR analysis and optimization. Even ignoring that the intrinsics are opaque to most optimizations, the read barrier can't even be marked readonly. Therefore, the most optimal output is probably be achieved by propagating knowledge about the GC model into the front-end, emitting simple loads and stores when allowed by the GC.</div><div><br></div><div>Chris has observed that read and write barriers lowering could equally well be implemented by the front-end with no special compiler support. The only significant value these these intrinsics add is if they <i>are</i> transparent to optimizations—e.g., if @llvm.gcreads of the same SSA value are coalesced even though @llvm.gcread can have side effects. This is an area for future work.</div><div><br></div></div>— Gordon<br class="Apple-interchange-newline"></span></span></span></span></span></div></span> </div></div><div><br></div></body></html>