[compiler-rt] r191190 - [ASan/Win] Slightly optimize the DLL thunk
Reid Kleckner
rnk at google.com
Mon Sep 23 10:48:03 PDT 2013
"slightly?" More like hugely. ;)
However, local statics are not thread safe with MSVC yet. You may want to
use something like InitOnceExecuteOnce:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683493(v=vs.85).aspx
On Mon, Sep 23, 2013 at 4:40 AM, Timur Iskhodzhanov <timurrrr at google.com>wrote:
> Author: timurrrr
> Date: Mon Sep 23 06:40:58 2013
> New Revision: 191190
>
> URL: http://llvm.org/viewvc/llvm-project?rev=191190&view=rev
> Log:
> [ASan/Win] Slightly optimize the DLL thunk
>
> Modified:
> compiler-rt/trunk/lib/asan/asan_dll_thunk.cc
>
> Modified: compiler-rt/trunk/lib/asan/asan_dll_thunk.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_dll_thunk.cc?rev=191190&r1=191189&r2=191190&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_dll_thunk.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_dll_thunk.cc Mon Sep 23 06:40:58 2013
> @@ -38,63 +38,63 @@ static void *getRealProcAddressOrDie(con
> #define WRAP_V_V(name)
> \
> extern "C" void name() {
> \
> typedef void (*fntype)();
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> fn();
> \
> }
>
> #define WRAP_V_W(name)
> \
> extern "C" void name(void *arg) {
> \
> typedef void (*fntype)(void *arg);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> fn(arg);
> \
> }
>
> #define WRAP_V_WW(name)
> \
> extern "C" void name(void *arg1, void *arg2) {
> \
> typedef void (*fntype)(void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> fn(arg1, arg2);
> \
> }
>
> #define WRAP_V_WWW(name)
> \
> extern "C" void name(void *arg1, void *arg2, void *arg3) {
> \
> typedef void *(*fntype)(void *, void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> fn(arg1, arg2, arg3);
> \
> }
>
> #define WRAP_W_V(name)
> \
> extern "C" void *name() {
> \
> typedef void *(*fntype)();
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn();
> \
> }
>
> #define WRAP_W_W(name)
> \
> extern "C" void *name(void *arg) {
> \
> typedef void *(*fntype)(void *arg);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg);
> \
> }
>
> #define WRAP_W_WW(name)
> \
> extern "C" void *name(void *arg1, void *arg2) {
> \
> typedef void *(*fntype)(void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg1, arg2);
> \
> }
>
> #define WRAP_W_WWW(name)
> \
> extern "C" void *name(void *arg1, void *arg2, void *arg3) {
> \
> typedef void *(*fntype)(void *, void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg1, arg2, arg3);
> \
> }
>
> #define WRAP_W_WWWW(name)
> \
> extern "C" void *name(void *arg1, void *arg2, void *arg3, void *arg4) {
> \
> typedef void *(*fntype)(void *, void *, void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg1, arg2, arg3, arg4);
> \
> }
>
> @@ -102,7 +102,7 @@ static void *getRealProcAddressOrDie(con
> extern "C" void *name(void *arg1, void *arg2, void *arg3, void *arg4,
> \
> void *arg5) {
> \
> typedef void *(*fntype)(void *, void *, void *, void *, void *);
> \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg1, arg2, arg3, arg4, arg5);
> \
> }
>
> @@ -110,7 +110,7 @@ static void *getRealProcAddressOrDie(con
> extern "C" void *name(void *arg1, void *arg2, void *arg3, void *arg4,
> \
> void *arg5, void *arg6) {
> \
> typedef void *(*fntype)(void *, void *, void *, void *, void *, void
> *); \
> - fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> + static fntype fn = (fntype)getRealProcAddressOrDie(#name);
> \
> return fn(arg1, arg2, arg3, arg4, arg5, arg6);
> \
> }
> // }}}
>
>
> _______________________________________________
> 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/20130923/8e76abae/attachment.html>
More information about the llvm-commits
mailing list