[PATCH] D77515: [mlir] Remove need for static global ctors from mlir-translate

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 5 16:02:03 PDT 2020


stephenneuendorffer added inline comments.


================
Comment at: mlir/include/mlir/InitAllTranslations.h:30
+inline void registerAllTranslations() {
+  static bool init_once = []() {
+    registerFromLLVMIRTranslation();
----------------
jroelofs wrote:
> stephenneuendorffer wrote:
> > nit: "init_once" is a little misleading, since this doesn't actually ensure that.
> Thought that was guaranteed with this pattern C++. What case am I missing?
> 
> 
> > If multiple threads attempt to initialize the same static local variable concurrently, the initialization occurs exactly once
> 
> https://en.cppreference.com/w/cpp/language/storage_duration#Static_local_variables
You're right.. I misparsed the code when I scanned it. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77515/new/

https://reviews.llvm.org/D77515





More information about the llvm-commits mailing list