<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 12, 2013, at 10:24 AM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div 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 dir="ltr">How is this different from ManagedStatic?</div></div></blockquote><div dir="auto"><br></div><div dir="auto">It's not!  I didn't know that this existed, and now I do.  I will use that instead!</div><br><blockquote type="cite"><div 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 dir="ltr"><div><br></div><div>Also, we don't yet have portable threadsafe static locals (even though they're in C++11) because we support building with MSVC and they haven't implemented it yet.</div></div></div></blockquote><div><br></div><div>Got it, didn't know that MSVC had this issue.</div><br><blockquote type="cite"><div 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 dir="ltr"><div><br></div><div>Are you sure your change preserves the ThreadLocal-ness of tlIsRecoveringFromCrash?</div></div></div></blockquote><div><br></div><div>If it was the case that my IsRecoveringFromCrash() always returns a pointer to the same thread-local and that thread-local's construction is thread-safe (which won't be the case in MSVC according to your comment above), then I believe it would.</div><div><br></div><div>I'll roll a new patch that uses ManagedStatic.  Thanks for the review!</div><div><br></div><div>-Filip</div><div><br></div><br><blockquote type="cite"><div 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="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 11, 2013 at 11:57 PM, Filip Pizlo<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:fpizlo@apple.com" target="_blank">fpizlo@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><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;">It would be great to eventually get to not having global constructors and exit-time destructors in LLVM.  It's a tough goal, but I thought I'd take care of some easy ones first, to establish some idioms.  So it would be good to decide if the idiom that this patch uses is scalable.  Clearly it isn't going to address CommandLine, but there are a bunch of things that it could address.<br><br>The idiom looks as follows.  If you wanted to write:<br><br>static Foo gMyFoo;<br><br>Then you should instead write:<br><br>static Foo& MyFoo() {<br> <span class="Apple-converted-space"> </span>static Foo *foo = new Foo();<br> <span class="Apple-converted-space"> </span>return *foo;<br>}<br><br>This is better in two ways:<br><br>- Foo::Foo is called only when and if you actually use MyFoo(), and not eagerly when the code is loaded.  This helps start-up time.<br>- Foo::~Foo isn't called during exit, so if the program into which llvm is embedded does an exit() on one thread while still using llvm on another thread, you won't get a race.  This allows programs that embed llvm to exit cleanly.<br><br>I considered adding some #define magic to make this idiom easier to write; but I abstained from doing that for now.  I'm curious, though, if the following would be cool:<br><br>#define DEFINE_STATIC(name, type, arguments) \<br> <span class="Apple-converted-space"> </span>static type& name() { \<br>   <span class="Apple-converted-space"> </span>static type *result = new type arguments; \<br>   <span class="Apple-converted-space"> </span>return *result; \<br> <span class="Apple-converted-space"> </span>}<br><br>Which would then allow MyFoo above to be defined as:<br><br>DEFINE_STATIC(Foo, MyFoo, ());<br><br>-Filip<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br><br></blockquote></div><br></div></div><br class="Apple-interchange-newline"></blockquote></div><br></body></html>