<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">On Oct 11, 2016, at 10:10 AM, Michael Gottesman &lt;<a href="mailto:mgottesman@apple.com" class="">mgottesman@apple.com</a>&gt; wrote:<br class=""><div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">&gt;<span style="font-family: -webkit-standard;" class="">If ARC Code Motion wishes to move the ARC semantics of ownership qualified</span><span style="font-family: -webkit-standard;" class="">&nbsp;</span><code class="highlighter-rouge">load</code><span style="font-family: -webkit-standard;" class="">,</span><span style="font-family: -webkit-standard;" class="">&nbsp;</span><code class="highlighter-rouge">store</code><span style="font-family: -webkit-standard;" class="">&nbsp;</span><span style="font-family: -webkit-standard;" class="">instructions, it must now consider read/write effects. On the other hand, it will be able to now not consider the side-effects of destructors when moving retain/release operations.</span><div class=""><div class=""><br class=""></div><div class="">Can you elaborate on what you mean by this? &nbsp;Does this mean the ARC optimizer has additional freedom somehow to ignore side effects in deinits? &nbsp;What grants that ability?</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Sorry for not being clear.</div><div class=""><br class=""></div><div class="">deinits in ARC are not sequenced with respect to memory operations in normal control flow, but if ARC performs any code motion, we must ensure that memory safety is respected. Such semantics are not new.</div><div class=""><br class=""></div><div class="">The main change here is that previously there were situations where we would split up the load/retain in a load [copy] operation. Then if the right things occured, we could cause the object to be deallocated before we use the value or took full ownership of the value.</div></div></div></div></blockquote><div><br class=""></div><div>Ah, I see what you mean. &nbsp;Got it.</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">In this case, we would be passing off to useD a deallocated instance of class D1 which would be undefined behavior.</div><div class=""><br class=""></div><div class="">So as long as for these load [copy] operations, we move the load/retain fused together, we can guarantee that an object is produced instantaneously in a safe way without any worry.</div><div class=""><br class=""></div><div class="">Was this helpful?</div></div></div></blockquote><br class=""></div><div>Yep, totally. &nbsp;The new approach is much more clear, thanks Michael!</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><br class=""></body></html>