[PATCH] Don't use ManagedStatic.

Yaron Keren yaron.keren at gmail.com
Mon Jun 8 05:37:52 PDT 2015


Here is the discussion

 http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-June/074015.html

We could go forward with this patch, mingw-w64 support may have improved
since then, a year ago, if there are still problems with mingw support of
call_once, #ifdef __MINGW32__ the previous solution.
No reason for all other compilers paying the price.

Yaron


2015-06-08 15:12 GMT+03:00 Aaron Ballman <aaron at aaronballman.com>:

> We had to revert use of call_once last year because MinGW did not
> support it. IIRC, there were a few other issues as well (I have a
> vague recollection of an issue with MSVC as well). May want to check
> old mailing list posts, as well as the other toolchains, to see how
> feasible this is.
>
> ~Aaron
>
> On Mon, Jun 8, 2015 at 3:36 AM, Rui Ueyama <ruiu at google.com> wrote:
> > Hi rafael,
> >
> > ManagedStatic is slow at least on Windows because it calls
> sys::MemoryFence
> > on every access. MSVC profiler reported that LLD is spending 9% on this
> function.
> > This patch is to avoid using that wrapper class and use call_once
> instead.
> >
> > http://reviews.llvm.org/D10303
> >
> > Files:
> >   lib/Object/Error.cpp
> >
> > Index: lib/Object/Error.cpp
> > ===================================================================
> > --- lib/Object/Error.cpp
> > +++ lib/Object/Error.cpp
> > @@ -13,7 +13,7 @@
> >
> >  #include "llvm/Object/Error.h"
> >  #include "llvm/Support/ErrorHandling.h"
> > -#include "llvm/Support/ManagedStatic.h"
> > +#include <mutex>
> >
> >  using namespace llvm;
> >  using namespace object;
> > @@ -55,8 +55,10 @@
> >                     "defined.");
> >  }
> >
> > -static ManagedStatic<_object_error_category> error_category;
> > -
> >  const std::error_category &object::object_category() {
> > -  return *error_category;
> > +  static _object_error_category *Ret;
> > +  static std::once_flag Flag;
> > +  if (Ret == nullptr)
> > +    std::call_once(Flag, []() { Ret = new _object_error_category(); });
> > +  return *Ret;
> >  }
> >
> > EMAIL PREFERENCES
> >   http://reviews.llvm.org/settings/panel/emailpreferences/
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/591e5f7e/attachment.html>


More information about the llvm-commits mailing list