[PATCH] Removing the static initializer in ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex.

Reid Kleckner rnk at google.com
Thu Oct 23 10:10:39 PDT 2014


>>! In D5922#4, @beanz wrote:
> Fixed code comments based on Aaron's feedback.
> 
> Aaron, I understand your point about using the Windows one-time initialization, however I'm really not the best candidate to write Windows specific code. I am much more familiar with basic threading constructs like MemFence and CompareAndSwap than Win32 APIs. Could you provide and test a Windows one-time init solution?

The one time initialization APIs were added in Vista, and I don't know if we've dropped support for XP or not yet. Certainly Microsoft has. =/

I suspect that the fence and CAS implementation has subtle issues, but I'm not a C++ memory model expert. David Majnemer has a better understanding, and he said there are issues.

When I pointed him at this, he told me the template interface I recommended was a bad idea. Maybe having llvm::once_flag and llvm::call_once that alias the std:: variants when available is the way to go. WDYT?

http://reviews.llvm.org/D5922






More information about the llvm-commits mailing list