aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2010-10-14 17:26:06 +0000
committerOwen Anderson <resistor@mac.com>2010-10-14 17:26:06 +0000
commit05b4af7078f846aea6bc1e51fea1f38aa2a41803 (patch)
treefda41ec8d8df45518398eef675ceee16f73b44eb /include
parent2d294f564b1eed29682b11d7165ea5800015cfcf (diff)
downloadexternal_llvm-05b4af7078f846aea6bc1e51fea1f38aa2a41803.zip
external_llvm-05b4af7078f846aea6bc1e51fea1f38aa2a41803.tar.gz
external_llvm-05b4af7078f846aea6bc1e51fea1f38aa2a41803.tar.bz2
Apparently MSVC doesn't support thread-safe static local initialization. Roll our own solution instead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/PassSupport.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h
index e0e4e8a..a81af56 100644
--- a/include/llvm/PassSupport.h
+++ b/include/llvm/PassSupport.h
@@ -24,7 +24,7 @@
#include "Pass.h"
#include "llvm/PassRegistry.h"
#include "llvm/InitializePasses.h"
-#include "llvm/Support/Compiler.h"
+#include "llvm/System/Atomic.h"
#include <vector>
namespace llvm {
@@ -137,10 +137,10 @@ private:
return PI; \
} \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- ATTRIBUTE_USED \
- static void* initialized = initialize##passName##PassOnce(Registry); \
- } \
- static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis);
+ static sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) initialize##passName##PassOnce(Registry); \
+ }
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
static void* initialize##passName##PassOnce(PassRegistry &Registry) {
@@ -157,10 +157,10 @@ private:
return PI; \
} \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- ATTRIBUTE_USED \
- static void* initialized = initialize##passName##PassOnce(Registry); \
- } \
- static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis);
+ static sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) initialize##passName##PassOnce(Registry); \
+ }
template<typename PassName>
Pass *callDefaultCtor() { return new PassName(); }
@@ -244,10 +244,11 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
return AI; \
} \
void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
- ATTRIBUTE_USED static void* initialized = \
- initialize##agName##AnalysisGroupOnce(Registry); \
- } \
- static RegisterAnalysisGroup<agName> agName##_info (name);
+ static sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) initialize##agName##AnalysisGroupOnce(Registry); \
+ }
+
#define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
static void* initialize##passName##PassOnce(PassRegistry &Registry) { \
@@ -260,11 +261,11 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
return AI; \
} \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- ATTRIBUTE_USED \
- static void* initialized = initialize##passName##PassOnce(Registry); \
- } \
- static RegisterPass<passName> passName ## _info(arg, name, cfg, analysis); \
- static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info);
+ static sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) initialize##passName##PassOnce(Registry); \
+ }
+
#define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
static void* initialize##passName##PassOnce(PassRegistry &Registry) {
@@ -279,11 +280,10 @@ struct RegisterAnalysisGroup : public RegisterAGBase {
return AI; \
} \
void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
- ATTRIBUTE_USED \
- static void* initialized = initialize##passName##PassOnce(Registry); \
- } \
- static RegisterPass<passName> passName ## _info(arg, n, cfg, analysis); \
- static RegisterAnalysisGroup<agName, def> passName ## _ag(passName ## _info);
+ static sys::cas_flag initialized = 0; \
+ sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
+ if (old_val == 0) initialize##passName##PassOnce(Registry); \
+ }
//===---------------------------------------------------------------------------
/// PassRegistrationListener class - This class is meant to be derived from by