llvm.org GIT mirror llvm / 9decc2e
Revert "[LPM] Replace the CALL_ONCE_... macro in the legacy pass manager with the new llvm::call_once facility." Fallback path doesn't compile. This reverts commit r271652. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271657 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
2 changed file(s) with 30 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
376376 Registry.registerPass(*PI, true); \
377377 return PI; \
378378 } \
379 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
380379 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
381 call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
382 std::ref(Registry)); \
380 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
383381 }
384382
385383 /// This initializer registers TargetMachine constructor, so the pass being
2525 #include "llvm/PassInfo.h"
2626 #include "llvm/PassRegistry.h"
2727 #include "llvm/Support/Atomic.h"
28 #include "llvm/Support/Threading.h"
29 #include
3028
3129 namespace llvm {
3230
3331 class TargetMachine;
32
33 #define CALL_ONCE_INITIALIZATION(function) \
34 static volatile sys::cas_flag initialized = 0; \
35 sys::cas_flag old_val = sys::CompareAndSwap(&initialized, 1, 0); \
36 if (old_val == 0) { \
37 function(Registry); \
38 sys::MemoryFence(); \
39 TsanIgnoreWritesBegin(); \
40 TsanHappensBefore(&initialized); \
41 initialized = 2; \
42 TsanIgnoreWritesEnd(); \
43 } else { \
44 sys::cas_flag tmp = initialized; \
45 sys::MemoryFence(); \
46 while (tmp != 2) { \
47 tmp = initialized; \
48 sys::MemoryFence(); \
49 } \
50 } \
51 TsanHappensAfter(&initialized);
3452
3553 #define INITIALIZE_PASS(passName, arg, name, cfg, analysis) \
3654 static void *initialize##passName##PassOnce(PassRegistry &Registry) { \
4058 Registry.registerPass(*PI, true); \
4159 return PI; \
4260 } \
43 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
44 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
45 call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
46 std::ref(Registry)); \
61 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
62 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
4763 }
4864
4965 #define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis) \
6076 Registry.registerPass(*PI, true); \
6177 return PI; \
6278 } \
63 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
64 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
65 call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
66 std::ref(Registry)); \
79 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
80 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
6781 }
6882
6983 #define INITIALIZE_PASS_WITH_OPTIONS(PassName, Arg, Name, Cfg, Analysis) \
151165 Registry.registerAnalysisGroup(&agName::ID, 0, *AI, false, true); \
152166 return AI; \
153167 } \
154 LLVM_DEFINE_ONCE_FLAG(Initialize##agName##AnalysisGroupFlag); \
155168 void llvm::initialize##agName##AnalysisGroup(PassRegistry &Registry) { \
156 call_once(Initialize##agName##AnalysisGroupFlag, \
157 initialize##agName##AnalysisGroupOnce, std::ref(Registry)); \
169 CALL_ONCE_INITIALIZATION(initialize##agName##AnalysisGroupOnce) \
158170 }
159171
160172 #define INITIALIZE_AG_PASS(passName, agName, arg, name, cfg, analysis, def) \
171183 true); \
172184 return AI; \
173185 } \
174 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
175 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
176 call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
177 std::ref(Registry)); \
186 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
187 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
178188 }
179189
180190 #define INITIALIZE_AG_PASS_BEGIN(passName, agName, arg, n, cfg, analysis, def) \
192202 Registry.registerAnalysisGroup(&agName::ID, &passName::ID, *AI, def, true); \
193203 return AI; \
194204 } \
195 LLVM_DEFINE_ONCE_FLAG(Initialize##passName##PassFlag); \
196 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
197 call_once(Initialize##passName##PassFlag, initialize##passName##PassOnce, \
198 std::ref(Registry)); \
205 void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
206 CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
199207 }
200208
201209 //===---------------------------------------------------------------------------