[PATCH] D19271: Change CALL_ONCE_INITIALIZATION implementation to use static initialization
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 17:21:07 PDT 2016
joker.eph added inline comments.
================
Comment at: include/llvm/PassSupport.h:35
@@ +34,3 @@
+#define CALL_ONCE_INITIALIZATION(function) \
+ static bool init_once([&] { \
+ function(Registry); \
----------------
kcc wrote:
> kcc wrote:
> > Mmm. I am probably missing something trivial (c++11-ish), but how is this going to work?
> > For me it looks like you define a static bool function, but never call it.
> Aaaah, init_once is a bool variable, not a function. Oh, how much this is confusing...
> Will this work with the versions of Visual C++ we use for LLVM?
> I remember that static initialization was broken there (until recently?)
>
> Why not std::call_once?
Yeah it would deserve a comment probably :)
I don't know if static initialization is safe in MSVC 2013 (I know it was announced to be "fixed", but don't know which version).
`std::call_once` require `<mutex>`, and I was worried of portability (I had trouble last time I tried to include it), and because of that we have an abstraction of mutex in libSupport I believe).
http://reviews.llvm.org/D19271
More information about the llvm-commits
mailing list