<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 19, 2014, at 6:43 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Sat, Oct 18, 2014 at 11:06 AM, Duncan P. N. Exon Smith<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:dexonsmith@apple.com" target="_blank" class="">dexonsmith@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class="">> On 2014 Oct 17, at 10:08, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:<br class="">><br class="">> I'm floating the idea that the right fix might be to drop the code, yes. We do this will null pointer dereferences and other cases of UB already (& yes, in LTO this means you might get some surprises - it's rather the nature of UB and optimizations).<br class="">><br class="">>> Coming back to the patch in itself, I also don’t see how it could be the wrong thing to do. The TrackingVH in the MDNode is meant to handle the case of the Value going away. RAUWing with a void value is just another case of a vanishing value.<br class="">><br class="">> I don't think it's really the same though, or at least I don't think it's clean that it needs to be the same. It's a pretty weird way for a value to go away & I'd consider not accepting it as a valid way for a value to go away without, possibly, a stronger example of where this is a reasonable way for a value to go away.<br class=""><br class=""></span>I guess you're suggesting that optimizations shouldn't be allowed to<br class="">RAUW a non-void instruction to a void one.  Assuming all the IR `Use`s<br class="">have been updated,<span class="Apple-converted-space"> </span></blockquote><div class=""><br class=""></div><div class="">What uses of a void value can/could exist? I assume I can't have an Instruction who's operand is a void value... <br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">this RAUW seems legitimate -- it's the only way to<br class="">update all the ValueHandles to the instruction.</blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">I think you'd need strong justification to remove this feature.</blockquote><div class=""><br class="">I suppose the narrower claim would be: If an Instruction has (even debug/metadata) uses, you can't replace all its uses with a void value.</div></div></div></blockquote><div><br class=""></div><div>You are aware of that, but I’ll mention it anyway. This sentence makes it look like having a debug metadata node referencing a value could change the outcome of an optimization. That would be very bad.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""> I don't think it's too unreasonable to ask for a single example of a reasonable use of this feature if we're going to consciously support it.<br class=""></div></div></div></blockquote><div><br class=""></div><div>I tried hard to come up with non-UB code that triggers this code path but couldn’t find one that gets us exactly in that situation. Using the DeadArgumentElimination pass to remove the unused return value gets us close, but it special cases a replacement by a void value by setting all references to a null value.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="">Though I appreciate orthogonality of features and the ability to RAUW any value, even one with no uses, if its compatible with its users (a value with no uses is trivially compatible with all its users). But once this requires explicit support, I'm not sure how orthogonal it is.<br class=""></div></div></div></blockquote><div><br class=""></div><div>Would you prefer a patch that introduces an assert in the MDNode RAUW callback and that special cases the introduction of a void call in InstCombine (In the same way it is done in DAE for example) ? </div><div><br class=""></div><div>Fred</div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="">- David</div></div></div></blockquote></div><br class=""></body></html>