<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="">What about the lock that is taken?<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">MutexGuard</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Lock(*</span><span style="font-variant-ligatures: no-common-ligatures" class="">getManagedStaticMutex</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">());</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">— </span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">Mehdi</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div><div style=""><blockquote type="cite" class=""><div class="">On Dec 25, 2016, at 11:14 PM, Viacheslav Nikolaev via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Though it won't actually help to guard this: while (StaticList) - a fence here is needed...</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 26, 2016 at 9:20 AM, Viacheslav Nikolaev <span dir="ltr" class=""><<a href="mailto:viacheslav.nikolaev@gmail.com" target="_blank" class="">viacheslav.nikolaev@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Ptr member of ManagedStaticBase is now atomic.<div class="">In ManagedStaticBase::<wbr class="">RegisterManagedStatic we have such code:<br class=""></div><div class=""><br class=""></div><div class=""><div class="">      void *Tmp = Creator();</div><div class=""><br class=""></div><div class="">      Ptr.store(Tmp, std::memory_order_release);</div><div class="">      DeleterFn = Deleter;</div><div class="">      </div><div class="">      // Add to list of managed statics.</div><div class="">      Next = StaticList;</div><div class="">      StaticList = this;</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">StaticList is not atomic and not guarded by any fence.</div><div class="">The same applies to the members DeleterFn and Next.</div><div class=""><br class=""></div><div class="">Doesn't it seem reasonable to change the code to</div><div class=""><br class=""></div><div class=""><div class="">      DeleterFn = Deleter;</div><div class="">      </div><div class="">      // Add to list of managed statics.</div><div class="">      Next = StaticList;</div><div class="">      StaticList = this;</div></div><div class="">      Ptr.store(Tmp, std::memory_order_release);</div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>